@unocss/svelte-scoped 0.52.3 → 0.52.5
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/preprocess.cjs +4 -2
- package/dist/preprocess.d.ts +1 -1
- package/dist/preprocess.mjs +4 -2
- package/dist/vite.cjs +6 -4
- package/dist/vite.mjs +6 -4
- package/package.json +4 -4
package/dist/preprocess.cjs
CHANGED
|
@@ -135,7 +135,7 @@ async function sortClassesIntoCategories(body, options, uno, filename) {
|
|
|
135
135
|
return { rulesToGenerate, ignore };
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const expressionsRE =
|
|
138
|
+
const expressionsRE = /\S*{[^{}]+?}\S*/g;
|
|
139
139
|
const classesRE = /(["'\`])([\S\s]+?)\1/g;
|
|
140
140
|
async function processExpressions(body, options, uno, filename) {
|
|
141
141
|
const rulesToGenerate = {};
|
|
@@ -391,7 +391,7 @@ function getChildNodeValue(childNode, applyVariables) {
|
|
|
391
391
|
return removeOuterQuotes(childNode.value.value.trim());
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
function UnocssSveltePreprocess(options = {}, unoContextFromVite) {
|
|
394
|
+
function UnocssSveltePreprocess(options = {}, unoContextFromVite, isViteBuild) {
|
|
395
395
|
if (!options.classPrefix)
|
|
396
396
|
options.classPrefix = "spu-";
|
|
397
397
|
let uno;
|
|
@@ -399,6 +399,8 @@ function UnocssSveltePreprocess(options = {}, unoContextFromVite) {
|
|
|
399
399
|
markup: async ({ content, filename }) => {
|
|
400
400
|
if (!uno)
|
|
401
401
|
uno = await getGenerator(options.configOrPath, unoContextFromVite);
|
|
402
|
+
if (isViteBuild && !options.combine)
|
|
403
|
+
options.combine = isViteBuild();
|
|
402
404
|
return await transformClasses({ content, filename: filename || "", uno, options });
|
|
403
405
|
},
|
|
404
406
|
style: async ({ content, attributes, filename }) => {
|
package/dist/preprocess.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { U as UnocssSveltePreprocessOptions, S as SvelteScopedContext } from './
|
|
|
3
3
|
export { S as SvelteScopedContext, a as TransformApplyOptions, T as TransformClassesOptions, U as UnocssSveltePreprocessOptions } from './types.d-48b837f0.js';
|
|
4
4
|
import '@unocss/core';
|
|
5
5
|
|
|
6
|
-
declare function UnocssSveltePreprocess(options?: UnocssSveltePreprocessOptions, unoContextFromVite?: SvelteScopedContext): PreprocessorGroup;
|
|
6
|
+
declare function UnocssSveltePreprocess(options?: UnocssSveltePreprocessOptions, unoContextFromVite?: SvelteScopedContext, isViteBuild?: () => boolean): PreprocessorGroup;
|
|
7
7
|
|
|
8
8
|
export { UnocssSveltePreprocess as default };
|
package/dist/preprocess.mjs
CHANGED
|
@@ -128,7 +128,7 @@ async function sortClassesIntoCategories(body, options, uno, filename) {
|
|
|
128
128
|
return { rulesToGenerate, ignore };
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
const expressionsRE =
|
|
131
|
+
const expressionsRE = /\S*{[^{}]+?}\S*/g;
|
|
132
132
|
const classesRE = /(["'\`])([\S\s]+?)\1/g;
|
|
133
133
|
async function processExpressions(body, options, uno, filename) {
|
|
134
134
|
const rulesToGenerate = {};
|
|
@@ -384,7 +384,7 @@ function getChildNodeValue(childNode, applyVariables) {
|
|
|
384
384
|
return removeOuterQuotes(childNode.value.value.trim());
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
function UnocssSveltePreprocess(options = {}, unoContextFromVite) {
|
|
387
|
+
function UnocssSveltePreprocess(options = {}, unoContextFromVite, isViteBuild) {
|
|
388
388
|
if (!options.classPrefix)
|
|
389
389
|
options.classPrefix = "spu-";
|
|
390
390
|
let uno;
|
|
@@ -392,6 +392,8 @@ function UnocssSveltePreprocess(options = {}, unoContextFromVite) {
|
|
|
392
392
|
markup: async ({ content, filename }) => {
|
|
393
393
|
if (!uno)
|
|
394
394
|
uno = await getGenerator(options.configOrPath, unoContextFromVite);
|
|
395
|
+
if (isViteBuild && !options.combine)
|
|
396
|
+
options.combine = isViteBuild();
|
|
395
397
|
return await transformClasses({ content, filename: filename || "", uno, options });
|
|
396
398
|
},
|
|
397
399
|
style: async ({ content, attributes, filename }) => {
|
package/dist/vite.cjs
CHANGED
|
@@ -11,14 +11,16 @@ require('magic-string');
|
|
|
11
11
|
require('css-tree');
|
|
12
12
|
|
|
13
13
|
function PassPreprocessToSveltePlugin(options = {}, ctx) {
|
|
14
|
+
let commandIsBuild = true;
|
|
15
|
+
const isBuild = () => commandIsBuild;
|
|
14
16
|
return {
|
|
15
17
|
name: "unocss:svelte-scoped:pass-preprocess",
|
|
16
18
|
enforce: "pre",
|
|
17
|
-
configResolved(
|
|
18
|
-
|
|
19
|
+
configResolved({ command }) {
|
|
20
|
+
commandIsBuild = command === "build";
|
|
19
21
|
},
|
|
20
22
|
api: {
|
|
21
|
-
sveltePreprocess: preprocess(options, ctx)
|
|
23
|
+
sveltePreprocess: preprocess(options, ctx, isBuild)
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
}
|
|
@@ -75,7 +77,7 @@ async function generateGlobalCss(uno, injectReset) {
|
|
|
75
77
|
}
|
|
76
78
|
const SVELTE_ERROR = `[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your index.html file.
|
|
77
79
|
`;
|
|
78
|
-
const SVELTE_KIT_ERROR = `[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your app.html file. You also need to have a transformPageChunk hook in your server
|
|
80
|
+
const SVELTE_KIT_ERROR = `[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your app.html file. You also need to have a transformPageChunk hook in your hooks.server.js file with: \`html.replace('${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}', '${GLOBAL_STYLES_PLACEHOLDER}')\`. You can see an example of the usage at https://github.com/unocss/unocss/tree/main/examples/sveltekit-scoped.`;
|
|
79
81
|
function checkTransformPageChunkHook(server, isSvelteKit) {
|
|
80
82
|
server.middlewares.use((req, res, next) => {
|
|
81
83
|
const originalWrite = res.write;
|
package/dist/vite.mjs
CHANGED
|
@@ -9,14 +9,16 @@ import 'magic-string';
|
|
|
9
9
|
import 'css-tree';
|
|
10
10
|
|
|
11
11
|
function PassPreprocessToSveltePlugin(options = {}, ctx) {
|
|
12
|
+
let commandIsBuild = true;
|
|
13
|
+
const isBuild = () => commandIsBuild;
|
|
12
14
|
return {
|
|
13
15
|
name: "unocss:svelte-scoped:pass-preprocess",
|
|
14
16
|
enforce: "pre",
|
|
15
|
-
configResolved(
|
|
16
|
-
|
|
17
|
+
configResolved({ command }) {
|
|
18
|
+
commandIsBuild = command === "build";
|
|
17
19
|
},
|
|
18
20
|
api: {
|
|
19
|
-
sveltePreprocess: UnocssSveltePreprocess(options, ctx)
|
|
21
|
+
sveltePreprocess: UnocssSveltePreprocess(options, ctx, isBuild)
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
}
|
|
@@ -73,7 +75,7 @@ async function generateGlobalCss(uno, injectReset) {
|
|
|
73
75
|
}
|
|
74
76
|
const SVELTE_ERROR = `[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your index.html file.
|
|
75
77
|
`;
|
|
76
|
-
const SVELTE_KIT_ERROR = `[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your app.html file. You also need to have a transformPageChunk hook in your server
|
|
78
|
+
const SVELTE_KIT_ERROR = `[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your app.html file. You also need to have a transformPageChunk hook in your hooks.server.js file with: \`html.replace('${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}', '${GLOBAL_STYLES_PLACEHOLDER}')\`. You can see an example of the usage at https://github.com/unocss/unocss/tree/main/examples/sveltekit-scoped.`;
|
|
77
79
|
function checkTransformPageChunkHook(server, isSvelteKit) {
|
|
78
80
|
server.middlewares.use((req, res, next) => {
|
|
79
81
|
const originalWrite = res.write;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/svelte-scoped",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.52.
|
|
4
|
+
"version": "0.52.5",
|
|
5
5
|
"description": "Use UnoCSS in a modular fashion with styles being stored only in the Svelte component they are used in: Vite plugin for apps, preprocessor for component libraries",
|
|
6
6
|
"author": "Jacob Bowdoin",
|
|
7
7
|
"license": "MIT",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"css-tree": "^2.3.1",
|
|
56
56
|
"magic-string": "^0.30.0",
|
|
57
|
-
"@unocss/config": "0.52.
|
|
58
|
-
"@unocss/reset": "0.52.
|
|
57
|
+
"@unocss/config": "0.52.5",
|
|
58
|
+
"@unocss/reset": "0.52.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"prettier-plugin-svelte": "^2.10.
|
|
61
|
+
"prettier-plugin-svelte": "^2.10.1",
|
|
62
62
|
"svelte": "^3.59.1"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|