@unocss/nuxt 0.60.3 → 0.60.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +40 -16
- package/package.json +14 -14
package/dist/index.d.mts
CHANGED
|
@@ -34,6 +34,12 @@ interface UnocssNuxtOptions extends UserConfig {
|
|
|
34
34
|
* @default true
|
|
35
35
|
*/
|
|
36
36
|
disableNuxtInlineStyle?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Automatically merge UnoCSS configs from Nuxt layers.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
nuxtLayers?: boolean;
|
|
37
43
|
/**
|
|
38
44
|
* Adjust the position of the `uno.css` injection. (Depends on `mode`)
|
|
39
45
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,12 @@ interface UnocssNuxtOptions extends UserConfig {
|
|
|
34
34
|
* @default true
|
|
35
35
|
*/
|
|
36
36
|
disableNuxtInlineStyle?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Automatically merge UnoCSS configs from Nuxt layers.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
nuxtLayers?: boolean;
|
|
37
43
|
/**
|
|
38
44
|
* Adjust the position of the `uno.css` injection. (Depends on `mode`)
|
|
39
45
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname, resolve } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import process from 'node:process';
|
|
4
|
-
import { defineNuxtModule, addPluginTemplate, isNuxt2, addComponentsDir,
|
|
4
|
+
import { defineNuxtModule, addPluginTemplate, isNuxt2, addComponentsDir, addTemplate, findPath, extendWebpackConfig, isNuxt3 } from '@nuxt/kit';
|
|
5
5
|
import WebpackPlugin from '@unocss/webpack';
|
|
6
6
|
import VitePlugin from '@unocss/vite';
|
|
7
7
|
import { loadConfig } from '@unocss/config';
|
|
@@ -56,6 +56,7 @@ const index = defineNuxtModule({
|
|
|
56
56
|
preflight: false,
|
|
57
57
|
components: true,
|
|
58
58
|
disableNuxtInlineStyle: true,
|
|
59
|
+
nuxtLayers: false,
|
|
59
60
|
// presets
|
|
60
61
|
uno: true,
|
|
61
62
|
attributify: false,
|
|
@@ -94,22 +95,44 @@ const index = defineNuxtModule({
|
|
|
94
95
|
watch: false
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
if (options.nuxtLayers) {
|
|
99
|
+
addTemplate({
|
|
100
|
+
filename: "uno.config.mjs",
|
|
101
|
+
async getContents() {
|
|
102
|
+
const configPaths = (await Promise.all(nuxt.options._layers.map(
|
|
103
|
+
(layer) => findPath(options.configFile || ["uno.config", "unocss.config"], { cwd: layer.config.srcDir })
|
|
104
|
+
))).filter(Boolean).reverse();
|
|
105
|
+
return `import { mergeConfigs } from '@unocss/core'
|
|
106
|
+
${configPaths.map((path, index) => `import cfg${index} from '${path}'`.trimStart()).join("\n").trimEnd()}
|
|
107
|
+
|
|
108
|
+
export default mergeConfigs([${configPaths.map((_, index) => `cfg${index}`).join(", ")}])
|
|
109
|
+
`;
|
|
110
|
+
},
|
|
111
|
+
write: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async function loadUnoConfig() {
|
|
115
|
+
const { config: unoConfig } = await loadConfig(process.cwd(), {
|
|
116
|
+
configFile: options.nuxtLayers ? resolve(nuxt.options.buildDir, "uno.config.mjs") : options.configFile
|
|
117
|
+
}, [], options);
|
|
118
|
+
await nuxt.callHook("unocss:config", unoConfig);
|
|
119
|
+
if (isNuxt3() && nuxt.options.builder === "@nuxt/vite-builder" && nuxt.options.postcss.plugins.cssnano && unoConfig.transformers?.some((t) => t.name === "@unocss/transformer-directives" && t.enforce !== "pre")) {
|
|
120
|
+
const preset = nuxt.options.postcss.plugins.cssnano.preset;
|
|
121
|
+
nuxt.options.postcss.plugins.cssnano = {
|
|
122
|
+
preset: [preset?.[0] || "default", Object.assign(
|
|
123
|
+
{ mergeRules: false, normalizeWhitespace: false, discardComments: false },
|
|
124
|
+
preset?.[1]
|
|
125
|
+
)]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return unoConfig;
|
|
109
129
|
}
|
|
110
|
-
nuxt.hook("vite:extend", ({ config }) => {
|
|
130
|
+
nuxt.hook("vite:extend", async ({ config }) => {
|
|
131
|
+
const unoConfig = await loadUnoConfig();
|
|
111
132
|
config.plugins = config.plugins || [];
|
|
112
|
-
config.plugins.unshift(...VitePlugin({
|
|
133
|
+
config.plugins.unshift(...VitePlugin({
|
|
134
|
+
mode: options.mode
|
|
135
|
+
}, unoConfig));
|
|
113
136
|
});
|
|
114
137
|
if (nuxt.options.dev) {
|
|
115
138
|
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
@@ -133,7 +156,8 @@ const index = defineNuxtModule({
|
|
|
133
156
|
config.plugins = [plugin];
|
|
134
157
|
});
|
|
135
158
|
}
|
|
136
|
-
extendWebpackConfig((config) => {
|
|
159
|
+
extendWebpackConfig(async (config) => {
|
|
160
|
+
const unoConfig = await loadUnoConfig();
|
|
137
161
|
config.plugins = config.plugins || [];
|
|
138
162
|
config.plugins.unshift(WebpackPlugin({}, unoConfig));
|
|
139
163
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.60.
|
|
4
|
+
"version": "0.60.4",
|
|
5
5
|
"description": "Nuxt module for UnoCSS",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@nuxt/kit": "^3.11.2",
|
|
42
|
-
"@unocss/config": "0.60.
|
|
43
|
-
"@unocss/core": "0.60.
|
|
44
|
-
"@unocss/preset-attributify": "0.60.
|
|
45
|
-
"@unocss/preset-
|
|
46
|
-
"@unocss/preset-
|
|
47
|
-
"@unocss/preset-typography": "0.60.
|
|
48
|
-
"@unocss/preset-uno": "0.60.
|
|
49
|
-
"@unocss/preset-web-fonts": "0.60.
|
|
50
|
-
"@unocss/
|
|
51
|
-
"@unocss/
|
|
52
|
-
"@unocss/vite": "0.60.
|
|
53
|
-
"@unocss/webpack": "0.60.
|
|
54
|
-
"unocss": "0.60.
|
|
42
|
+
"@unocss/config": "0.60.4",
|
|
43
|
+
"@unocss/core": "0.60.4",
|
|
44
|
+
"@unocss/preset-attributify": "0.60.4",
|
|
45
|
+
"@unocss/preset-icons": "0.60.4",
|
|
46
|
+
"@unocss/preset-tagify": "0.60.4",
|
|
47
|
+
"@unocss/preset-typography": "0.60.4",
|
|
48
|
+
"@unocss/preset-uno": "0.60.4",
|
|
49
|
+
"@unocss/preset-web-fonts": "0.60.4",
|
|
50
|
+
"@unocss/reset": "0.60.4",
|
|
51
|
+
"@unocss/preset-wind": "0.60.4",
|
|
52
|
+
"@unocss/vite": "0.60.4",
|
|
53
|
+
"@unocss/webpack": "0.60.4",
|
|
54
|
+
"unocss": "0.60.4"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@nuxt/schema": "^3.11.2"
|