@unocss/nuxt 0.8.1 → 0.9.3

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/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  Nuxt module for UnoCSS
4
4
 
5
+ ## Supporting Status
6
+
7
+ | | Nuxt 2 | Nuxt Bridge | Nuxt 3 |
8
+ | --- | --- | --- | --- |
9
+ | Webpack Dev | ✅ | ✅ | 🚧 |
10
+ | Webpack Build | ✅ | ✅ | ✅ |
11
+ | Vite Dev | - | ✅ | ✅ |
12
+ | Vite Build | - | ✅ | ✅ |
13
+
5
14
  ## Installation
6
15
 
7
16
  ```bash
@@ -14,7 +23,10 @@ npm i -g @unocss/nuxt
14
23
  export default {
15
24
  buildModules: [
16
25
  '@unocss/nuxt'
17
- ]
26
+ ],
27
+ unocss: {
28
+ // options
29
+ }
18
30
  }
19
31
  ```
20
32
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,53 @@
1
1
  import * as _nuxt_kit from '@nuxt/kit';
2
+ import { UserConfig } from '@unocss/core';
3
+ import { AttributifyOptions } from '@unocss/preset-attributify';
4
+ import { IconsOptions } from '@unocss/preset-icons';
2
5
 
6
+ interface UnocssNuxtOptions extends UserConfig {
7
+ /**
8
+ * Injecting `uno.css` entry
9
+ *
10
+ * @default true
11
+ */
12
+ autoImport?: boolean;
13
+ /**
14
+ * Injecting `@unocss/reset/tailwind.css` entry
15
+ *
16
+ * @default false
17
+ */
18
+ preflight?: boolean;
19
+ /**
20
+ * Installing UnoCSS components
21
+ * - `<UnoIcon>`
22
+ *
23
+ * @default true
24
+ */
25
+ components?: boolean;
26
+ /**
27
+ * Enable the default preset
28
+ * Only works when `presets` is not specified
29
+ * @default true
30
+ */
31
+ uno?: boolean;
32
+ /**
33
+ * Enable attributify mode and the options of it
34
+ * Only works when `presets` is not specified
35
+ * @default false
36
+ */
37
+ attributify?: boolean | AttributifyOptions;
38
+ /**
39
+ * Enable icons preset and the options of it
40
+ * Only works when `presets` is not specified
41
+ * @default false
42
+ */
43
+ icons?: boolean | IconsOptions;
44
+ }
3
45
  declare const _default: _nuxt_kit.LegacyNuxtModule;
4
46
 
5
- export { _default as default };
47
+ declare module '@nuxt/kit' {
48
+ interface ConfigSchema {
49
+ unocss?: UnocssNuxtOptions;
50
+ }
51
+ }
52
+
53
+ export { UnocssNuxtOptions, _default as default };
package/dist/index.mjs CHANGED
@@ -2,29 +2,58 @@
2
2
  import { dirname, resolve } from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  import { defineNuxtModule, extendViteConfig, extendWebpackConfig, addPluginTemplate, addComponentsDir } from "@nuxt/kit";
5
- import Unocss from "unocss/vite";
5
+ import presetUno from "@unocss/preset-uno";
6
+ import presetAttributify from "@unocss/preset-attributify";
7
+ import presetIcons from "@unocss/preset-icons";
8
+ import WebpackPlugin from "@unocss/webpack";
9
+ import VitePlugin from "@unocss/vite";
6
10
  var dir = dirname(fileURLToPath(import.meta.url));
7
11
  var src_default = defineNuxtModule({
8
12
  name: "unocss",
9
- defaults: {},
13
+ defaults: {
14
+ autoImport: true,
15
+ components: true,
16
+ uno: true
17
+ },
10
18
  configKey: "unocss",
11
- setup(options, nuxt) {
12
- nuxt.options.alias["/_nuxt/@unocss-entry.css"] = "/@unocss-entry.css";
13
- addPluginTemplate({
14
- filename: "unocss.mjs",
15
- src: "",
16
- getContents: () => "import 'uno.css';export default () => {};"
17
- });
18
- addComponentsDir({
19
- path: resolve(dir, "../runtime"),
20
- watch: false
21
- });
19
+ setup(options) {
20
+ if (options.presets == null) {
21
+ options.presets = [];
22
+ if (options.uno)
23
+ options.presets.push(presetUno());
24
+ if (options.attributify)
25
+ options.presets.push(presetAttributify(typeof options.attributify == "boolean" ? {} : options.attributify));
26
+ if (options.icons)
27
+ options.presets.push(presetIcons(typeof options.icons == "boolean" ? {} : options.icons));
28
+ }
29
+ if (options.autoImport) {
30
+ addPluginTemplate({
31
+ filename: "unocss.mjs",
32
+ src: "",
33
+ getContents: () => {
34
+ const lines = [
35
+ "import 'uno.css'",
36
+ "export default () => {};"
37
+ ];
38
+ if (options.preflight)
39
+ lines.unshift("import '@unocss/reset/tailwind.css'");
40
+ return lines.join("\n");
41
+ }
42
+ });
43
+ }
44
+ if (options.components) {
45
+ addComponentsDir({
46
+ path: resolve(dir, "../runtime"),
47
+ watch: false
48
+ });
49
+ }
22
50
  extendViteConfig((config) => {
23
51
  config.plugins = config.plugins || [];
24
- config.plugins.unshift(...Unocss(options));
52
+ config.plugins.unshift(...VitePlugin(options));
25
53
  });
26
- extendWebpackConfig(() => {
27
- throw new Error("UnoCSS does not support Webpack at this moment");
54
+ extendWebpackConfig((config) => {
55
+ config.plugins = config.plugins || [];
56
+ config.plugins.unshift(WebpackPlugin(options));
28
57
  });
29
58
  }
30
59
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/nuxt",
3
- "version": "0.8.1",
3
+ "version": "0.9.3",
4
4
  "description": "Nuxt module for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -36,7 +36,13 @@
36
36
  "runtime"
37
37
  ],
38
38
  "dependencies": {
39
- "unocss": "0.8.1",
39
+ "@unocss/core": "0.9.3",
40
+ "@unocss/webpack": "0.9.3",
41
+ "@unocss/vite": "0.9.3",
42
+ "@unocss/reset": "0.9.3",
43
+ "@unocss/preset-uno": "0.9.3",
44
+ "@unocss/preset-attributify": "0.9.3",
45
+ "@unocss/preset-icons": "0.9.3",
40
46
  "@nuxt/kit": "npm:@nuxt/kit-edge@latest"
41
47
  },
42
48
  "scripts": {