@unocss/transformer-directives 0.32.7 → 0.32.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/LICENSE +1 -1
- package/README.md +2 -0
- package/dist/index.cjs +1 -3
- package/dist/index.mjs +2 -4
- package/package.json +3 -4
package/LICENSE
CHANGED
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const core = require('@unocss/core');
|
|
6
6
|
const cssTree = require('css-tree');
|
|
7
7
|
|
|
8
|
-
const regexCssId = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
9
|
-
|
|
10
8
|
function transformerDirectives(options = {}) {
|
|
11
9
|
return {
|
|
12
10
|
name: "css-directive",
|
|
13
11
|
enforce: options?.enforce,
|
|
14
|
-
idFilter: (id) => !!id.match(
|
|
12
|
+
idFilter: (id) => !!id.match(core.cssIdRE),
|
|
15
13
|
transform: (code, id, ctx) => {
|
|
16
14
|
return transformDirectives(code, ctx.uno, options, id);
|
|
17
15
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { expandVariantGroup, notNull, regexScopePlaceholder } from '@unocss/core';
|
|
1
|
+
import { cssIdRE, expandVariantGroup, notNull, regexScopePlaceholder } from '@unocss/core';
|
|
2
2
|
import { parse, walk, generate, clone } from 'css-tree';
|
|
3
3
|
|
|
4
|
-
const regexCssId = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
5
|
-
|
|
6
4
|
function transformerDirectives(options = {}) {
|
|
7
5
|
return {
|
|
8
6
|
name: "css-directive",
|
|
9
7
|
enforce: options?.enforce,
|
|
10
|
-
idFilter: (id) => !!id.match(
|
|
8
|
+
idFilter: (id) => !!id.match(cssIdRE),
|
|
11
9
|
transform: (code, id, ctx) => {
|
|
12
10
|
return transformDirectives(code, ctx.uno, options, id);
|
|
13
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.11",
|
|
4
4
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unocss/core": "0.32.
|
|
34
|
+
"@unocss/core": "0.32.11",
|
|
35
35
|
"css-tree": "^2.1.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -40,6 +40,5 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "unbuild",
|
|
42
42
|
"stub": "unbuild --stub"
|
|
43
|
-
}
|
|
44
|
-
"readme": "# @unocss/transformer-directives\n\nUnoCSS transformer for `@apply` directive\n\n## Install\n\n```bash\nnpm i -D @unocss/transformer-directives\n```\n\n```ts\nimport Unocss from 'unocss/vite'\nimport transformerDirective from '@unocss/transformer-directives'\n\nUnocss({\n transformers: [\n transformerDirective(),\n ],\n})\n```\n\n## Usage\n\n```css\n.custom-div {\n @apply text-center my-0 font-medium;\n}\n```\n\nWill be transformed to:\n\n```css\n.custom-div {\n margin-top: 0rem;\n margin-bottom: 0rem;\n text-align: center;\n font-weight: 500;\n}\n```\n\n> Currently only `@apply` is supported.\n\n### CSS Variable Style\n\nTo be compatible with vanilla CSS, you can use CSS Variables to replace the `@apply` directive.\n\n```css\n.custom-div {\n --at-apply: text-center my-0 font-medium;\n}\n```\n\nTo use rules with `:`, you will need to quote the value\n\n```css\n.custom-div {\n --at-apply: \"hover:text-red\";\n}\n```\n\nThis feature is enabled by default (with prefix `--at-`), can you configure it or disable it via:\n\n```js\ntransformerDirective({\n varStyle: '--my-at-',\n // or disable with:\n // varStyle: false\n})\n```\n\n## License\n\nMIT License © 2022-PRESENT [hannoeru](https://github.com/hannoeru)\n"
|
|
43
|
+
}
|
|
45
44
|
}
|