Skip to content

Public assets (JS & CSS) ​

A module ships its own JavaScript, CSS, and other static files from its public/ folder, outside the main Vite bundle. oneCRM copies that folder into the web root when the module is enabled.

Source and published paths ​

LocationPath
Source (in your module)modules/{ModuleName}/public/
Published (web-accessible)public/modules/{module}/

{module} is the lowercase module name from module.json (Tickets → public/modules/tickets/).

The copy is made when the module is enabled. After changing files in the module's public/ folder, run php artisan module:enable MyFeature again.

Plain static files ​

modules/MyFeature/
├── public/
│   ├── chart.js
│   └── styles.css
└── module.json

Reference them by the published path:

blade
<script src="{{ asset('modules/myfeature/chart.js') }}"></script>
<link rel="stylesheet" href="{{ asset('modules/myfeature/styles.css') }}">

Vite assets ​

module:make --with-vite scaffolds vite.config.js, package.json and empty resources/js/app.js and resources/css/app.css entry files. They build with @onecrm/module-vite, a local package in packages/onecrm/module-vite that ships with oneCRM (it is not on npm):

bash
cd packages/onecrm/module-vite
npm install

cd ../../../modules/MyFeature
npm install
js
import { defineModuleConfig } from '@onecrm/module-vite'

export default defineModuleConfig({
  input: ['resources/css/app.css', 'resources/js/app.js'],
})

Besides input, defineModuleConfig accepts laravel, build, plugins, vite and configure to override its defaults.

Register the same entry points in your module definition. oneCRM then adds their tags to every admin and customer portal page:

php
$module->vite(['resources/css/app.css', 'resources/js/app.js']);
CommandUse
npm run devDevelopment, with hot reload
npm run buildDevelopment build, written straight to public/modules/myfeature/build/
npm run build-isolatedRelease build, written to the module's own public/build/

WARNING

Always run npm run build-isolated before zipping. npm run build writes into the application's public/ tree, not into your module.

ZIP releases ​

Ship public/build/ inside the ZIP - customers do not run npm. Building a release ZIP runs build-isolated for you when the module's node_modules/ is installed.

modules/MyFeature/
├── public/
│   └── build/          ← output of npm run build-isolated
│       ├── manifest.json
│       └── assets/...
├── resources/js/
├── vite.config.js
└── module.json

Layout classes ​

The CRM ships its CSS precompiled, so a Tailwind class in your module's Blade works only if that CSS already contains it. These layout classes are always included:

GroupClassesWith sm: md: lg: xl:
Displayblock, inline-block, inline, flex, inline-flex, grid, hidden, contentsYes
Flexflex-row, flex-col, flex-wrap, flex-1, grow, shrink-0, items-{start,center,end,baseline,stretch}, justify-{start,center,end,between}, self-{start,center,end}Direction, wrap, items, justify
Gridgrid-cols-1…12, col-span-1…12, col-span-full, grid-rows-1…6Columns and spans
Orderorder-first, order-last, order-1…6md: and lg:
Gapgap-*, gap-x-*, gap-y-*Yes
Spacingp*-* and m*-* (all sides), m-auto, mx-auto, my-auto, space-x-*, space-y-*No
Width and heightw-full, w-auto, w-1/2, w-1/3, w-2/3, w-1/4, w-3/4, min-w-0, max-w-xs…max-w-7xl, max-w-full, size-4/5/6, h-*, h-auto, h-full, h-screen, min-h-0, min-h-full, min-h-screen, max-h-fullw-* only
Positionstatic, relative, absolute, fixed, sticky, top/right/bottom/left/start/end/inset/inset-x/inset-y-* (with auto and full), -top/-right/-bottom/-left-{0.5,1,2}, translate-x-1/2, translate-y-1/2 and their negatives, z-0…z-50, z-autoNo
Texttext-left, text-center, text-right, text-xs…text-2xl, font-medium, font-semibold, truncate, whitespace-nowrap, break-wordsAlignment
Overflowoverflow-hidden, overflow-auto, overflow-x-autoNo

* is the spacing scale: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10, 12.

Any other class may be missing from the shipped CSS. For colors use the tokens below; for the rest, write your own CSS with the theme variables.

Colors and dark mode ​

Every interface color is a token with a light and a dark value, so a module that uses the tokens follows the theme and dark mode without a dark: class of its own.

TokenUse it for
text-strongHeadings, values and anything read first
text-secondarySubheadings, labels and supporting text
text-mutedHints, placeholders and help text
border-edge / ring-edgeThe outline of an object: a card, an input, a button
border-edge-softerA soft outline for cards that repeat down a list
border-divider / divide-dividerA line inside content, between rows or sections
bg-surfaceCards and panels on the page
bg-surface-mutedA tinted tray or panel
hover:bg-tint / hover:bg-tint-softHover in menus and navigation / hover on rows and controls in a card
bg-accent / text-accent-foregroundA fill in the configured accent color, and the text on it
text-accent-contentAccent-colored text

Keep status and data colors (a red overdue badge, a chart series) as your own colors; the tokens are for the neutral interface around them.

In your own CSS, read the theme as variables instead of repeating values:

css
.myfeature-timeline::before {
    background-color: var(--color-divider);
    border-radius: var(--radius-lg);
    padding: calc(var(--spacing) * 4);
}
ValueVariable
Color tokens and palettevar(--color-divider), var(--color-strong), var(--color-amber-500)
Spacingcalc(var(--spacing) * 4)
Radii, shadows, font sizesvar(--radius-lg), var(--shadow-sm), var(--text-sm)

Media queries cannot read variables; write breakpoints in rem (sm 40rem, md 48rem, lg 64rem, xl 80rem).

WARNING

Keep a .dark { … } block that overrides a theme variable outside any @layer, or it has no effect: theme variables are defined outside the cascade layers, and unlayered rules always win.

See also ​

Giải pháp CRM Tinh gọn Tự lưu trữ - Sở hữu toàn quyền, không phụ phí định kỳ.