mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 12:17:54 +01:00
feat(module): add option to disable global css styles (#1266)
This commit is contained in:
@@ -227,12 +227,13 @@ You can also add the following to your `.vscode/settings.json` to enable Intelli
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
| Key | Default | Description |
|
| Key | Default | Description |
|
||||||
| ------------------------ | ---------------------- | ------------------------------------------------ |
|
|-----------------------|-----------------|-------------------------------------------------------------------------------------------------------------|
|
||||||
| `prefix` | `u` | Define the prefix of the imported components. |
|
| `prefix` | `u` | Define the prefix of the imported components. |
|
||||||
| `global` | `false` | Expose components globally. |
|
| `global` | `false` | Expose components globally. |
|
||||||
| `icons` | `['heroicons']` | Icon collections to load. |
|
| `icons` | `['heroicons']` | Icon collections to load. |
|
||||||
| `safelistColors` | `['primary']` | Force safelisting of colors to need be purged. |
|
| `safelistColors` | `['primary']` | Force safelisting of colors to need be purged. |
|
||||||
|
| `disableGlobalStyles` | `false` | Disable [global CSS styles](https://github.com/nuxt/ui/blob/dev/src/runtime/ui.css) injected by the module. |
|
||||||
|
|
||||||
Configure options in your `nuxt.config.ts` as such:
|
Configure options in your `nuxt.config.ts` as such:
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ export interface ModuleOptions {
|
|||||||
icons: CollectionNames[] | 'all' | IconsPluginOptions
|
icons: CollectionNames[] | 'all' | IconsPluginOptions
|
||||||
|
|
||||||
safelistColors?: string[]
|
safelistColors?: string[]
|
||||||
|
/**
|
||||||
|
* Disables the global css styles added by the module.
|
||||||
|
*/
|
||||||
|
disableGlobalStyles?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineNuxtModule<ModuleOptions>({
|
export default defineNuxtModule<ModuleOptions>({
|
||||||
@@ -68,7 +72,8 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
defaults: {
|
defaults: {
|
||||||
prefix: 'U',
|
prefix: 'U',
|
||||||
icons: ['heroicons'],
|
icons: ['heroicons'],
|
||||||
safelistColors: ['primary']
|
safelistColors: ['primary'],
|
||||||
|
disableGlobalStyles: false
|
||||||
},
|
},
|
||||||
async setup (options, nuxt) {
|
async setup (options, nuxt) {
|
||||||
const { resolve } = createResolver(import.meta.url)
|
const { resolve } = createResolver(import.meta.url)
|
||||||
@@ -80,7 +85,9 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
|
|
||||||
nuxt.options.alias['#ui'] = runtimeDir
|
nuxt.options.alias['#ui'] = runtimeDir
|
||||||
|
|
||||||
nuxt.options.css.push(resolve(runtimeDir, 'ui.css'))
|
if (!options.disableGlobalStyles) {
|
||||||
|
nuxt.options.css.push(resolve(runtimeDir, 'ui.css'))
|
||||||
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
nuxt.hook('tailwindcss:config', function (tailwindConfig) {
|
nuxt.hook('tailwindcss:config', function (tailwindConfig) {
|
||||||
|
|||||||
Reference in New Issue
Block a user