@unocss/vite 0.27.6 → 0.28.2
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 +22 -24
- package/package.json +17 -16
package/README.md
CHANGED
|
@@ -16,8 +16,8 @@ import Unocss from 'unocss/vite'
|
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
plugins: [
|
|
19
|
-
Unocss({ /* options */ })
|
|
20
|
-
]
|
|
19
|
+
Unocss({ /* options */ }),
|
|
20
|
+
],
|
|
21
21
|
}
|
|
22
22
|
```
|
|
23
23
|
|
|
@@ -81,7 +81,7 @@ export default {
|
|
|
81
81
|
Unocss({
|
|
82
82
|
/* options */
|
|
83
83
|
}),
|
|
84
|
-
]
|
|
84
|
+
],
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
@@ -98,7 +98,7 @@ export default {
|
|
|
98
98
|
Unocss({
|
|
99
99
|
/* options */
|
|
100
100
|
}),
|
|
101
|
-
]
|
|
101
|
+
],
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -116,8 +116,8 @@ export default {
|
|
|
116
116
|
Unocss({
|
|
117
117
|
/* options */
|
|
118
118
|
}),
|
|
119
|
-
react()
|
|
120
|
-
]
|
|
119
|
+
react(),
|
|
120
|
+
],
|
|
121
121
|
}
|
|
122
122
|
```
|
|
123
123
|
|
|
@@ -138,7 +138,7 @@ export default {
|
|
|
138
138
|
Unocss({
|
|
139
139
|
/* options */
|
|
140
140
|
}),
|
|
141
|
-
]
|
|
141
|
+
],
|
|
142
142
|
}
|
|
143
143
|
```
|
|
144
144
|
|
|
@@ -155,7 +155,7 @@ export default {
|
|
|
155
155
|
Unocss({
|
|
156
156
|
/* options */
|
|
157
157
|
}),
|
|
158
|
-
]
|
|
158
|
+
],
|
|
159
159
|
}
|
|
160
160
|
```
|
|
161
161
|
|
|
@@ -173,8 +173,8 @@ export default {
|
|
|
173
173
|
Unocss({
|
|
174
174
|
/* options */
|
|
175
175
|
}),
|
|
176
|
-
preact()
|
|
177
|
-
]
|
|
176
|
+
preact(),
|
|
177
|
+
],
|
|
178
178
|
}
|
|
179
179
|
```
|
|
180
180
|
|
|
@@ -200,8 +200,8 @@ export default {
|
|
|
200
200
|
extractors: [extractorSvelte],
|
|
201
201
|
/* more options */
|
|
202
202
|
}),
|
|
203
|
-
svelte()
|
|
204
|
-
]
|
|
203
|
+
svelte(),
|
|
204
|
+
],
|
|
205
205
|
}
|
|
206
206
|
```
|
|
207
207
|
|
|
@@ -224,9 +224,7 @@ const config = {
|
|
|
224
224
|
// Consult https://github.com/sveltejs/svelte-preprocess
|
|
225
225
|
// for more information about preprocessors
|
|
226
226
|
preprocess: preprocess(),
|
|
227
|
-
|
|
228
227
|
kit: {
|
|
229
|
-
|
|
230
228
|
// hydrate the <div id="svelte"> element in src/app.html
|
|
231
229
|
target: '#svelte',
|
|
232
230
|
vite: {
|
|
@@ -234,11 +232,11 @@ const config = {
|
|
|
234
232
|
UnoCss({
|
|
235
233
|
extractors: [extractorSvelte],
|
|
236
234
|
/* more options */
|
|
237
|
-
})
|
|
238
|
-
]
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
235
|
+
}),
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
}
|
|
242
240
|
```
|
|
243
241
|
|
|
244
242
|
You have a `SvelteKit` example project on [test/fixtures/sveltekit](https://github.com/unocss/unocss/tree/main/test/fixtures/sveltekit) directory.
|
|
@@ -259,7 +257,7 @@ export default {
|
|
|
259
257
|
mode: 'shadow-dom',
|
|
260
258
|
/* more options */
|
|
261
259
|
}),
|
|
262
|
-
]
|
|
260
|
+
],
|
|
263
261
|
}
|
|
264
262
|
```
|
|
265
263
|
|
|
@@ -314,7 +312,7 @@ export default {
|
|
|
314
312
|
],
|
|
315
313
|
/* more options */
|
|
316
314
|
}),
|
|
317
|
-
]
|
|
315
|
+
],
|
|
318
316
|
}
|
|
319
317
|
```
|
|
320
318
|
|
|
@@ -358,7 +356,7 @@ export default {
|
|
|
358
356
|
Unocss({
|
|
359
357
|
/* options */
|
|
360
358
|
}),
|
|
361
|
-
]
|
|
359
|
+
],
|
|
362
360
|
}
|
|
363
361
|
```
|
|
364
362
|
|
|
@@ -379,8 +377,8 @@ export default defineConfig({
|
|
|
379
377
|
elmPlugin(),
|
|
380
378
|
Unocss({
|
|
381
379
|
/* options */
|
|
382
|
-
})
|
|
383
|
-
]
|
|
380
|
+
}),
|
|
381
|
+
],
|
|
384
382
|
})
|
|
385
383
|
```
|
|
386
384
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.2",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -12,17 +12,16 @@
|
|
|
12
12
|
"url": "https://github.com/unocss/unocss/issues"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
+
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
|
17
18
|
"url": "git+https://github.com/unocss/unocss.git",
|
|
18
19
|
"directory": "packages/vite"
|
|
19
20
|
},
|
|
20
21
|
"funding": "https://github.com/sponsors/antfu",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"dist"
|
|
25
|
-
],
|
|
22
|
+
"main": "dist/index.cjs",
|
|
23
|
+
"module": "dist/index.mjs",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"require": "./dist/index.cjs",
|
|
@@ -30,16 +29,17 @@
|
|
|
30
29
|
"types": "./dist/index.d.ts"
|
|
31
30
|
}
|
|
32
31
|
},
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@rollup/pluginutils": "^4.
|
|
38
|
-
"@unocss/config": "0.
|
|
39
|
-
"@unocss/core": "0.
|
|
40
|
-
"@unocss/inspector": "0.
|
|
41
|
-
"@unocss/scope": "0.
|
|
42
|
-
"@unocss/transformer-directives": "0.
|
|
37
|
+
"@rollup/pluginutils": "^4.2.0",
|
|
38
|
+
"@unocss/config": "0.28.2",
|
|
39
|
+
"@unocss/core": "0.28.2",
|
|
40
|
+
"@unocss/inspector": "0.28.2",
|
|
41
|
+
"@unocss/scope": "0.28.2",
|
|
42
|
+
"@unocss/transformer-directives": "0.28.2",
|
|
43
43
|
"magic-string": "^0.26.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -48,5 +48,6 @@
|
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "unbuild",
|
|
50
50
|
"stub": "unbuild --stub"
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"readme": "# @unocss/vite\n\nThe Vite plugin for UnoCSS. Ships with the `unocss` package.\n\n> This plugin does not come with any default presets. You are building a meta framework on top of UnoCSS, see [this file](https://github.com/unocss/unocss/blob/main/packages/unocss/src/vite.ts) for an example to bind the default presets.\n\n## Installation\n\n```bash\nnpm i -D unocss\n```\n\n```ts\n// vite.config.ts\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n Unocss({ /* options */ }),\n ],\n}\n```\n\nAdd `uno.css` to your main entry:\n\n```ts\n// main.ts\nimport 'uno.css'\n```\n\n## Modes\n\nThe Vite plugin comes with a set of modes that enable different behaviors.\n\n### global (default)\n\nThis is the default mode for the plugin: in this mode you need to add the import of `uno.css` on your entry point.\n\nThis mode enables a set of Vite plugins for `build` and for `dev` with `HMR` support.\n\nThe generated `css` will be a global stylesheet injected on the `index.html`.\n\n### vue-scoped (WIP)\n\nThis mode will inject generated CSS to Vue SFC's `<style scoped>` for isolation.\n\n### svelte-scoped (WIP)\n\nThis mode will inject generated CSS to Svelte's `<style>` for isolation.\n\n### per-module (WIP)\n\nThis mode will generate a CSS sheet for each module, can be scoped.\n\n### dist-chunk (WIP)\n\nThis mode will generate a CSS sheet for each code chunk on build, great for MPA.\n\n### shadow-dom\n\nSince `Web Components` uses `Shadow DOM`, there is no way to style content directly from a global stylesheet (unless you use `custom css vars`, those will penetrate the `Shadow DOM`), you need to inline the generated css by the plugin into the `Shadow DOM` style.\n\nTo inline the generated css, you only need to configure the plugin mode to `shadow-dom` and include `@unocss-placeholder` magic placeholder on each web component style css block.\n\n## Frameworks\n\nSome UI/App frameworks have some caveats that must be fixed to make it work, if you're using one of the following frameworks, just apply the suggestions.\n\n### React\n\nIf you're using `@vitejs/plugin-react`:\n\n```ts\n// vite.config.js\nimport react from '@vitejs/plugin-react'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n react(),\n Unocss({\n /* options */\n }),\n ],\n}\n```\n\nor if you're using `@vitejs/plugin-react-refresh`:\n\n```ts\n// vite.config.js\nimport reactRefresh from '@vitejs/plugin-react-refresh'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n reactRefresh(),\n Unocss({\n /* options */\n }),\n ],\n}\n```\n\nIf you're using `@unocss/preset-attributify` you should remove `tsc` from the `build` script.\n\nIf you are using `@vitejs/plugin-react` with `@unocss/preset-attributify`, you must add the plugin before `@vitejs/plugin-react`.\n\n```ts\n// vite.config.js\nimport react from '@vitejs/plugin-react'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n Unocss({\n /* options */\n }),\n react(),\n ],\n}\n```\n\nYou have a `React` example project on [test/fixtures/vite-react](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-react) directory using both plugins, check the scripts on `package.json` and its Vite configuration file.\n\n### Preact\n\nIf you're using `@preact/preset-vite`:\n\n```ts\n// vite.config.js\nimport preact from '@preact/preset-vite'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n preact(),\n Unocss({\n /* options */\n }),\n ],\n}\n```\n\nor if you're using `@prefresh/vite`:\n\n```ts\n// vite.config.js\nimport prefresh from '@prefresh/vite'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n prefresh(),\n Unocss({\n /* options */\n }),\n ],\n}\n```\n\nIf you're using `@unocss/preset-attributify` you should remove `tsc` from the `build` script.\n\nIf you are using `@preact/preset-vite` with `@unocss/preset-attributify`, you must add the plugin before `@preact/preset-vite`.\n\n```ts\n// vite.config.js\nimport preact from '@preact/preset-vite'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n Unocss({\n /* options */\n }),\n preact(),\n ],\n}\n```\n\nYou have a `Preact` example project on [test/fixtures/vite-preact](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-preact) directory using both plugins, check the scripts on `package.json` and its Vite configuration file.\n\n### Svelte\n\nYou must add the plugin before `@sveltejs/vite-plugin-svelte`.\n\nTo support `class:foo` and `class:foo={bar}` add the plugin and configure `extractorSvelte` on `extractors` option.\n\nYou can use simple rules with `class:`, for example `class:bg-red-500={foo}` or using `shorcuts` to include multiples rules, see `src/App.svelte` on linked example project bellow.\n\n```ts\n// vite.config.js\nimport { svelte } from '@sveltejs/vite-plugin-svelte'\nimport Unocss from 'unocss/vite'\nimport { extractorSvelte } from '@unocss/core'\n\nexport default {\n plugins: [\n Unocss({\n extractors: [extractorSvelte],\n /* more options */\n }),\n svelte(),\n ],\n}\n```\n\nYou have a `Vite + Svelte` example project on [test/fixtures/vite-svelte](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-svelte) directory.\n\n### Sveltekit\n\nTo support `class:foo` and `class:foo={bar}` add the plugin and configure `extractorSvelte` on `extractors` option.\n\nYou can use simple rules with `class:`, for example `class:bg-red-500={foo}` or using `shorcuts` to include multiples rules, see `src/routes/__layout.svelte` on linked example project bellow.\n\n```ts\n// svelte.config.js\nimport preprocess from 'svelte-preprocess'\nimport UnoCss from 'unocss/vite'\nimport { extractorSvelte } from '@unocss/core'\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n // Consult https://github.com/sveltejs/svelte-preprocess\n // for more information about preprocessors\n preprocess: preprocess(),\n kit: {\n // hydrate the <div id=\"svelte\"> element in src/app.html\n target: '#svelte',\n vite: {\n plugins: [\n UnoCss({\n extractors: [extractorSvelte],\n /* more options */\n }),\n ],\n },\n },\n}\n```\n\nYou have a `SvelteKit` example project on [test/fixtures/sveltekit](https://github.com/unocss/unocss/tree/main/test/fixtures/sveltekit) directory.\n\n### Web Components\n\nTo work with web components you need to enable `shadow-dom` mode on the plugin.\n\nDon't forget to remove the import for `uno.css` since the `shadow-dom` mode will not expose it and the application will not work.\n\n```ts\n// vite.config.js\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n Unocss({\n mode: 'shadow-dom',\n /* more options */\n }),\n ],\n}\n```\n\nOn each `web component` just add `@unocss-placeholder` to its style css block:\n```ts\nconst template = document.createElement('template')\ntemplate.innerHTML = `\n<style>\n:host {...}\n@unocss-placeholder\n</style>\n<div class=\"m-1em\">\n...\n</div>\n`\n```\n\nIf you're using [Lit](https://lit.dev/):\n\n```ts\n@customElement('my-element')\nexport class MyElement extends LitElement {\n static styles = css`\n :host {...}\n @unocss-placeholder\n `\n ...\n}\n```\n\nYou have a `Web Components` example project on [test/fixtures/vite-lit](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-lit) directory.\n\n#### `::part` built-in support\n\nYou can use `::part` since the plugin supports it via `shortcuts` and using `part-[<part-name>]:<rule|shortcut>` rule from `preset-mini`, for example using it with simple rules like `part-[<part-name>]:bg-green-500` or using some `shortcut`: check `src/my-element.ts` on linked example project bellow.\n\nThe `part-[<part-name>]:<rule|shortcut>` will work only with this plugin using the `shadow-dom` mode.\n\nThe plugin uses `nth-of-type` to avoid collisions with multiple parts in the same web component and for the same parts on distinct web components, you don't need to worry about it, the plugin will take care for you.\n\n```ts\n// vite.config.js\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n Unocss({\n mode: 'shadow-dom',\n shortcuts: [\n { 'cool-blue': 'bg-blue-500 text-white' },\n { 'cool-green': 'bg-green-500 text-black' },\n ],\n /* more options */\n }),\n ],\n}\n```\n\nthen in your web components:\n\n```ts\n// my-container-wc.ts\nconst template = document.createElement('template')\ntemplate.innerHTML = `\n<style>\n@unocss-placeholder\n</style>\n<my-wc-with-parts class=\"part-[cool-part]:cool-blue part-[another-cool-part]:cool-green\">...</my-wc-with-parts>\n`\n```\n\n```ts\n// my-wc-with-parts.ts\nconst template = document.createElement('template')\ntemplate.innerHTML = `\n<style>\n@unocss-placeholder\n</style>\n<div>\n <div part=\"cool-part\">...</div>\n <div part=\"another-cool-part\">...</div>\n</div>\n`\n```\n\n### Solid\n\n```ts\n// vite.config.js\nimport solidPlugin from 'vite-plugin-solid'\nimport Unocss from 'unocss/vite'\n\nexport default {\n plugins: [\n solidPlugin(),\n Unocss({\n /* options */\n }),\n ],\n}\n```\n\nYou have a `Vite + Solid` example project on [test/fixtures/vite-solid](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-solid) directory.\n\n### Elm\n\nYou need to add the `vite-plugin-elm` plugin before UnoCSS's plugin.\n\n```ts\n// vite.config.js\nimport { defineConfig } from 'vite'\nimport elmPlugin from 'vite-plugin-elm'\nimport Unocss from 'unocss/vite'\n\nexport default defineConfig({\n plugins: [\n elmPlugin(),\n Unocss({\n /* options */\n }),\n ],\n})\n```\n\nYou have a `Vite + Elm` example project on [test/fixtures/vite-elm](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-elm) directory.\n\n## License\n\nMIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)\n"
|
|
52
53
|
}
|