@unocss/nuxt 66.5.10-beta.1 → 66.5.11

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.mjs CHANGED
@@ -1,163 +1,141 @@
1
- import { dirname, resolve } from 'node:path';
2
- import process from 'node:process';
3
- import { fileURLToPath } from 'node:url';
4
- import { defineNuxtModule, addPluginTemplate, addComponentsDir, addTemplate, findPath, isNuxtMajorVersion, extendViteConfig, extendWebpackConfig } from '@nuxt/kit';
5
- import { createRecoveryConfigLoader } from '@unocss/config';
6
- import { cssIdRE } from '@unocss/core';
7
- import presetAttributify from '@unocss/preset-attributify';
8
- import presetIcons from '@unocss/preset-icons';
9
- import presetTagify from '@unocss/preset-tagify';
10
- import presetTypography from '@unocss/preset-typography';
11
- import presetWebFonts from '@unocss/preset-web-fonts';
12
- import presetWind3 from '@unocss/preset-wind3';
13
- import presetWind4 from '@unocss/preset-wind4';
1
+ import { dirname, resolve } from "node:path";
2
+ import process from "node:process";
3
+ import { fileURLToPath } from "node:url";
4
+ import { addComponentsDir, addPluginTemplate, addTemplate, defineNuxtModule, extendViteConfig, extendWebpackConfig, findPath, isNuxtMajorVersion } from "@nuxt/kit";
5
+ import { createRecoveryConfigLoader } from "@unocss/config";
6
+ import { cssIdRE } from "@unocss/core";
7
+ import presetAttributify from "@unocss/preset-attributify";
8
+ import presetIcons from "@unocss/preset-icons";
9
+ import presetTagify from "@unocss/preset-tagify";
10
+ import presetTypography from "@unocss/preset-typography";
11
+ import presetWebFonts from "@unocss/preset-web-fonts";
12
+ import presetWind3 from "@unocss/preset-wind3";
13
+ import presetWind4 from "@unocss/preset-wind4";
14
14
 
15
+ //#region ../../virtual-shared/integration/src/defaults.ts
15
16
  const defaultPipelineExclude = [cssIdRE];
16
17
 
18
+ //#endregion
19
+ //#region src/options.ts
17
20
  function resolveOptions(options) {
18
- if (options.wind3 && options.wind4) {
19
- console.warn("[unocss/nuxt]: wind3 and wind4 presets are mutually exclusive. wind3 will be disabled in favor of wind4.");
20
- options.wind3 = false;
21
- }
22
- if (options.presets == null) {
23
- options.presets = [];
24
- const presetMap = {
25
- wind3: presetWind3,
26
- wind4: presetWind4,
27
- attributify: presetAttributify,
28
- icons: presetIcons,
29
- webFonts: presetWebFonts,
30
- typography: presetTypography,
31
- tagify: presetTagify
32
- };
33
- for (const [key, preset] of Object.entries(presetMap)) {
34
- const option = options[key];
35
- if (option) {
36
- options.presets.push(preset(typeof option === "boolean" ? {} : option));
37
- }
38
- }
39
- }
40
- options.content ??= {};
41
- options.content.pipeline ??= {};
42
- if (options.content.pipeline !== false) {
43
- options.content.pipeline.exclude ??= defaultPipelineExclude;
44
- if (Array.isArray(options.content.pipeline.exclude))
45
- options.content.pipeline.exclude.push(/\?macro=true/);
46
- }
21
+ if (options.wind3 && options.wind4) {
22
+ console.warn("[unocss/nuxt]: wind3 and wind4 presets are mutually exclusive. wind3 will be disabled in favor of wind4.");
23
+ options.wind3 = false;
24
+ }
25
+ if (options.presets == null) {
26
+ options.presets = [];
27
+ const presetMap = {
28
+ wind3: presetWind3,
29
+ wind4: presetWind4,
30
+ attributify: presetAttributify,
31
+ icons: presetIcons,
32
+ webFonts: presetWebFonts,
33
+ typography: presetTypography,
34
+ tagify: presetTagify
35
+ };
36
+ for (const [key, preset] of Object.entries(presetMap)) {
37
+ const option = options[key];
38
+ if (option) options.presets.push(preset(typeof option === "boolean" ? {} : option));
39
+ }
40
+ }
41
+ options.content ??= {};
42
+ options.content.pipeline ??= {};
43
+ if (options.content.pipeline !== false) {
44
+ options.content.pipeline.exclude ??= defaultPipelineExclude;
45
+ if (Array.isArray(options.content.pipeline.exclude)) options.content.pipeline.exclude.push(/\?macro=true/);
46
+ }
47
47
  }
48
48
 
49
+ //#endregion
50
+ //#region src/index.ts
49
51
  const dir = dirname(fileURLToPath(import.meta.url));
50
- const index = defineNuxtModule({
51
- meta: {
52
- name: "unocss",
53
- configKey: "unocss"
54
- },
55
- defaults: {
56
- mode: "global",
57
- autoImport: true,
58
- preflight: false,
59
- components: true,
60
- disableNuxtInlineStyle: true,
61
- nuxtLayers: false,
62
- // presets
63
- attributify: false,
64
- webFonts: false,
65
- icons: false,
66
- wind3: true,
67
- wind4: false
68
- },
69
- async setup(options, nuxt) {
70
- resolveOptions(options);
71
- const loadConfig = createRecoveryConfigLoader();
72
- options.mode ??= "global";
73
- const InjectModes = ["global", "dist-chunk"];
74
- if (options.disableNuxtInlineStyle) {
75
- nuxt.options.features ||= {};
76
- nuxt.options.features.inlineStyles = false;
77
- }
78
- if (options.injectPosition != null)
79
- console.warn("[unocss/nuxt] options `injectPosition` is temporary removed due to the incompatibility with Nuxt 3.9. We are seeking for better solution. It's not effective at this moment.");
80
- if (options.autoImport) {
81
- addPluginTemplate({
82
- filename: "unocss.mjs",
83
- getContents: () => {
84
- const lines = [
85
- InjectModes.includes(options.mode) ? "import 'uno.css'" : "",
86
- "import { defineNuxtPlugin } from '#imports'; export default defineNuxtPlugin(() => {})"
87
- ];
88
- if (options.preflight)
89
- lines.unshift("import '@unocss/reset/tailwind.css'");
90
- return lines.join("\n");
91
- }
92
- });
93
- }
94
- if (options.components) {
95
- addComponentsDir({
96
- path: resolve(dir, "../runtime"),
97
- watch: false
98
- });
99
- }
100
- if (options.nuxtLayers) {
101
- addTemplate({
102
- filename: "uno.config.mjs",
103
- async getContents() {
104
- const configPaths = (await Promise.all(nuxt.options._layers.slice(1).map(
105
- (layer) => findPath(options.configFile || ["uno.config", "unocss.config"], { cwd: layer.config.rootDir })
106
- ))).filter(Boolean).reverse();
107
- return `import { mergeConfigs } from '@unocss/core'
52
+ var src_default = defineNuxtModule({
53
+ meta: {
54
+ name: "unocss",
55
+ configKey: "unocss"
56
+ },
57
+ defaults: {
58
+ mode: "global",
59
+ autoImport: true,
60
+ preflight: false,
61
+ components: true,
62
+ disableNuxtInlineStyle: true,
63
+ nuxtLayers: false,
64
+ attributify: false,
65
+ webFonts: false,
66
+ icons: false,
67
+ wind3: true,
68
+ wind4: false
69
+ },
70
+ async setup(options, nuxt) {
71
+ resolveOptions(options);
72
+ const loadConfig = createRecoveryConfigLoader();
73
+ options.mode ??= "global";
74
+ const InjectModes = ["global", "dist-chunk"];
75
+ if (options.disableNuxtInlineStyle) {
76
+ nuxt.options.features ||= {};
77
+ nuxt.options.features.inlineStyles = false;
78
+ }
79
+ if (options.injectPosition != null) console.warn("[unocss/nuxt] options `injectPosition` is temporary removed due to the incompatibility with Nuxt 3.9. We are seeking for better solution. It's not effective at this moment.");
80
+ if (options.autoImport) addPluginTemplate({
81
+ filename: "unocss.mjs",
82
+ getContents: () => {
83
+ const lines = [InjectModes.includes(options.mode) ? "import 'uno.css'" : "", "import { defineNuxtPlugin } from '#imports'; export default defineNuxtPlugin(() => {})"];
84
+ if (options.preflight) lines.unshift("import '@unocss/reset/tailwind.css'");
85
+ return lines.join("\n");
86
+ }
87
+ });
88
+ if (options.components) addComponentsDir({
89
+ path: resolve(dir, "../runtime"),
90
+ watch: false
91
+ });
92
+ if (options.nuxtLayers) addTemplate({
93
+ filename: "uno.config.mjs",
94
+ async getContents() {
95
+ const configPaths = (await Promise.all(nuxt.options._layers.slice(1).map((layer) => findPath(options.configFile || ["uno.config", "unocss.config"], { cwd: layer.config.rootDir })))).filter(Boolean).reverse();
96
+ return `import { mergeConfigs } from '@unocss/core'
108
97
  ${configPaths.map((path, index) => `import cfg${index} from '${path}'`.trimStart()).join("\n").trimEnd()}
109
98
 
110
99
  export default mergeConfigs([${configPaths.map((_, index) => `cfg${index}`).join(", ")}])
111
100
  `;
112
- },
113
- write: true
114
- });
115
- }
116
- nuxt.hook("build:before", async () => {
117
- const { config: unoConfig } = await loadConfig(
118
- process.cwd(),
119
- { configFile: options.configFile },
120
- [],
121
- options
122
- );
123
- if (isNuxtMajorVersion(3, nuxt) && nuxt.options.builder === "@nuxt/vite-builder" && nuxt.options.postcss.plugins.cssnano && unoConfig.transformers?.some((t) => t.name === "@unocss/transformer-directives" && t.enforce !== "pre")) {
124
- const preset = nuxt.options.postcss.plugins.cssnano.preset;
125
- nuxt.options.postcss.plugins.cssnano = {
126
- preset: [preset?.[0] || "default", Object.assign(
127
- // Following optimizations result in invalid CSS if the directives not transformed yet
128
- { mergeRules: false, normalizeWhitespace: false, discardComments: false },
129
- preset?.[1]
130
- )]
131
- };
132
- }
133
- await nuxt.callHook("unocss:config", unoConfig);
134
- extendViteConfig(async (config) => {
135
- const { default: VitePlugin } = await import('@unocss/vite');
136
- config.plugins = config.plugins || [];
137
- config.plugins.unshift(...VitePlugin({
138
- mode: options.mode
139
- }, unoConfig));
140
- });
141
- extendWebpackConfig(async (config) => {
142
- const { default: WebpackPlugin } = await import('@unocss/webpack');
143
- config.plugins = config.plugins || [];
144
- config.plugins.unshift(WebpackPlugin({}, unoConfig));
145
- });
146
- });
147
- if (nuxt.options.dev) {
148
- nuxt.hook("devtools:customTabs", (tabs) => {
149
- tabs.push({
150
- title: "UnoCSS",
151
- name: "unocss",
152
- icon: "/__unocss/favicon.svg",
153
- view: {
154
- type: "iframe",
155
- src: "/__unocss/"
156
- }
157
- });
158
- });
159
- }
160
- }
101
+ },
102
+ write: true
103
+ });
104
+ nuxt.hook("build:before", async () => {
105
+ const { config: unoConfig } = await loadConfig(process.cwd(), { configFile: options.configFile }, [], options);
106
+ if (isNuxtMajorVersion(3, nuxt) && nuxt.options.builder === "@nuxt/vite-builder" && nuxt.options.postcss.plugins.cssnano && unoConfig.transformers?.some((t) => t.name === "@unocss/transformer-directives" && t.enforce !== "pre")) {
107
+ const preset = nuxt.options.postcss.plugins.cssnano.preset;
108
+ nuxt.options.postcss.plugins.cssnano = { preset: [preset?.[0] || "default", Object.assign({
109
+ mergeRules: false,
110
+ normalizeWhitespace: false,
111
+ discardComments: false
112
+ }, preset?.[1])] };
113
+ }
114
+ await nuxt.callHook("unocss:config", unoConfig);
115
+ extendViteConfig(async (config) => {
116
+ const { default: VitePlugin } = await import("@unocss/vite");
117
+ config.plugins = config.plugins || [];
118
+ config.plugins.unshift(...VitePlugin({ mode: options.mode }, unoConfig));
119
+ });
120
+ extendWebpackConfig(async (config) => {
121
+ const { default: WebpackPlugin } = await import("@unocss/webpack");
122
+ config.plugins = config.plugins || [];
123
+ config.plugins.unshift(WebpackPlugin({}, unoConfig));
124
+ });
125
+ });
126
+ if (nuxt.options.dev) nuxt.hook("devtools:customTabs", (tabs) => {
127
+ tabs.push({
128
+ title: "UnoCSS",
129
+ name: "unocss",
130
+ icon: "/__unocss/favicon.svg",
131
+ view: {
132
+ type: "iframe",
133
+ src: "/__unocss/"
134
+ }
135
+ });
136
+ });
137
+ }
161
138
  });
162
139
 
163
- export { index as default };
140
+ //#endregion
141
+ export { src_default as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/nuxt",
3
3
  "type": "module",
4
- "version": "66.5.10-beta.1",
4
+ "version": "66.5.11",
5
5
  "description": "Nuxt module for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -24,9 +24,14 @@
24
24
  "sideEffects": false,
25
25
  "exports": {
26
26
  ".": {
27
- "types": "./dist/index.d.mts",
28
- "require": "./index.cjs",
29
- "default": "./dist/index.mjs"
27
+ "import": {
28
+ "types": "./dist/index.d.mts",
29
+ "default": "./dist/index.mjs"
30
+ },
31
+ "require": {
32
+ "types": "./dist/index.d.cts",
33
+ "default": "./dist/index.cjs"
34
+ }
30
35
  }
31
36
  },
32
37
  "main": "dist/index.mjs",
@@ -34,28 +39,26 @@
34
39
  "types": "dist/index.d.ts",
35
40
  "files": [
36
41
  "dist",
37
- "index.cjs",
38
42
  "runtime"
39
43
  ],
40
44
  "dependencies": {
41
- "@nuxt/kit": "^4.2.1",
42
- "@unocss/config": "66.5.10-beta.1",
43
- "@unocss/core": "66.5.10-beta.1",
44
- "@unocss/preset-tagify": "66.5.10-beta.1",
45
- "@unocss/preset-attributify": "66.5.10-beta.1",
46
- "@unocss/preset-typography": "66.5.10-beta.1",
47
- "@unocss/preset-web-fonts": "66.5.10-beta.1",
48
- "@unocss/reset": "66.5.10-beta.1",
49
- "@unocss/preset-icons": "66.5.10-beta.1",
50
- "@unocss/preset-wind3": "66.5.10-beta.1",
51
- "@unocss/preset-wind4": "66.5.10-beta.1",
52
- "@unocss/vite": "66.5.10-beta.1",
53
- "unocss": "66.5.10-beta.1",
54
- "@unocss/webpack": "66.5.10-beta.1"
45
+ "@nuxt/kit": "^4.2.2",
46
+ "@unocss/config": "66.5.11",
47
+ "@unocss/core": "66.5.11",
48
+ "@unocss/preset-attributify": "66.5.11",
49
+ "@unocss/preset-tagify": "66.5.11",
50
+ "@unocss/preset-typography": "66.5.11",
51
+ "@unocss/preset-web-fonts": "66.5.11",
52
+ "@unocss/preset-icons": "66.5.11",
53
+ "@unocss/preset-wind3": "66.5.11",
54
+ "@unocss/reset": "66.5.11",
55
+ "@unocss/vite": "66.5.11",
56
+ "@unocss/webpack": "66.5.11",
57
+ "unocss": "66.5.11",
58
+ "@unocss/preset-wind4": "66.5.11"
55
59
  },
56
60
  "scripts": {
57
- "build": "unbuild",
58
- "stub": "unbuild --stub",
59
- "test:attw": "attw --pack"
61
+ "build": "tsdown --config-loader unrun",
62
+ "dev": "tsdown --config-loader unrun --watch"
60
63
  }
61
64
  }
package/dist/index.d.ts DELETED
@@ -1,123 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { UserConfig } from '@unocss/core';
3
- import { AttributifyOptions } from '@unocss/preset-attributify';
4
- import { IconsOptions } from '@unocss/preset-icons';
5
- import { TagifyOptions } from '@unocss/preset-tagify';
6
- import { TypographyOptions } from '@unocss/preset-typography';
7
- import { WebFontsOptions } from '@unocss/preset-web-fonts';
8
- import { PresetWind3Options } from '@unocss/preset-wind3';
9
- import { PresetWind4Options } from '@unocss/preset-wind4';
10
- import { VitePluginConfig } from '@unocss/vite';
11
-
12
- interface UnocssNuxtOptions extends UserConfig {
13
- /**
14
- * CSS Generation mode. Only work with Vite.
15
- *
16
- * @see https://unocss.dev/integrations/vite#modes
17
- */
18
- mode?: VitePluginConfig['mode'];
19
- /**
20
- * Injecting `uno.css` entry
21
- *
22
- * @default true
23
- */
24
- autoImport?: boolean;
25
- /**
26
- * Injecting `@unocss/reset/tailwind.css` entry
27
- *
28
- * @default false
29
- */
30
- preflight?: boolean;
31
- /**
32
- * Set Nuxt's `features.inlineStyle` to `false` by default to make it work with UnoCSS.
33
- *
34
- * @default true
35
- */
36
- disableNuxtInlineStyle?: boolean;
37
- /**
38
- * Automatically merge UnoCSS configs from Nuxt layers.
39
- *
40
- * @default false
41
- */
42
- nuxtLayers?: boolean;
43
- /**
44
- * Adjust the position of the `uno.css` injection. (Depends on `mode`)
45
- *
46
- * @default 'first'
47
- * @deprecated Temporarily removed, will be added back in the future.
48
- */
49
- injectPosition?: 'first' | 'last' | number | {
50
- after?: string;
51
- };
52
- /**
53
- * Installing UnoCSS components
54
- * - `<UnoIcon>`
55
- *
56
- * @default true
57
- */
58
- components?: boolean;
59
- /**
60
- * Enable attributify mode and the options of it
61
- * Only works when `presets` is not specified
62
- * @default false
63
- */
64
- attributify?: boolean | AttributifyOptions;
65
- /**
66
- * Enable tagify mode and the options of it
67
- * Only works when `presets` is not specified
68
- * @default false
69
- */
70
- tagify?: boolean | TagifyOptions;
71
- /**
72
- * Enable icons preset and the options of it
73
- * Only works when `presets` is not specified
74
- * @default false
75
- */
76
- icons?: boolean | IconsOptions;
77
- /**
78
- * Enable web fonts preset and the options of it
79
- * Only works when `presets` is not specified
80
- * @default false
81
- */
82
- webFonts?: boolean | WebFontsOptions;
83
- /**
84
- * Enable typography preset and the options of it
85
- * Only works when `presets` is not specified
86
- * @default false
87
- */
88
- typography?: boolean | TypographyOptions;
89
- /**
90
- * Enable the wind3 preset
91
- * Only works when `presets` is not specified
92
- * @default true
93
- */
94
- wind3?: boolean | PresetWind3Options;
95
- /**
96
- * Enable the wind4 preset
97
- * Only works when `presets` is not specified
98
- * @default false
99
- */
100
- wind4?: boolean | PresetWind4Options;
101
- }
102
- declare module '@nuxt/schema' {
103
- interface NuxtHooks {
104
- /**
105
- * When UnoCSS load config completed.
106
- */
107
- 'unocss:config': (config: UserConfig) => void;
108
- }
109
- }
110
-
111
- declare const _default: _nuxt_schema.NuxtModule<UnocssNuxtOptions, UnocssNuxtOptions, false>;
112
-
113
- declare module '@nuxt/schema' {
114
- interface NuxtConfig {
115
- unocss?: UnocssNuxtOptions;
116
- }
117
- interface NuxtOptions {
118
- unocss?: UnocssNuxtOptions;
119
- }
120
- }
121
-
122
- export { _default as default };
123
- export type { UnocssNuxtOptions };
package/index.cjs DELETED
@@ -1,10 +0,0 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true })
4
-
5
- // CommonJS proxy to bypass jiti transforms from nuxt 2 and using native ESM
6
- exports.default = function (...args) {
7
- return import('./dist/index.mjs').then(m => m.default.call(this, ...args))
8
- }
9
-
10
- module.exports.meta = require('./package.json')