@gjsify/rolldown-plugin-gjsify 0.16.1 → 0.16.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/lib/plugins/css-as-string.js +30 -4
- package/package.json +9 -8
|
@@ -183,11 +183,20 @@ export function cssAsStringPlugin(options = {}) {
|
|
|
183
183
|
return {
|
|
184
184
|
name: 'gjsify-css-as-string',
|
|
185
185
|
load: {
|
|
186
|
-
|
|
186
|
+
// Also match `.scss`/`.sass` — a Sass entry is compiled to flat CSS
|
|
187
|
+
// first (Sass already resolves its own `@use`/`@import`/partials and
|
|
188
|
+
// flattens nesting, so no further lightningcss lowering is needed).
|
|
189
|
+
filter: { id: /\.(css|s[ac]ss)$/ },
|
|
187
190
|
async handler(id) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
let code;
|
|
192
|
+
if (/\.s[ac]ss$/.test(id)) {
|
|
193
|
+
code = await compileSass(id);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
code = bundle
|
|
197
|
+
? new TextDecoder('utf-8').decode(await loadAndBundleCss(id, targets))
|
|
198
|
+
: await readFile(id, 'utf8');
|
|
199
|
+
}
|
|
191
200
|
return {
|
|
192
201
|
code: `export default ${JSON.stringify(code)};`,
|
|
193
202
|
moduleType: 'js',
|
|
@@ -196,6 +205,23 @@ export function cssAsStringPlugin(options = {}) {
|
|
|
196
205
|
},
|
|
197
206
|
};
|
|
198
207
|
}
|
|
208
|
+
let _sassPromise = null;
|
|
209
|
+
async function compileSass(filename) {
|
|
210
|
+
if (!_sassPromise) {
|
|
211
|
+
// Lazy + indirect specifier so `sass` is only resolved when a Sass file
|
|
212
|
+
// is actually imported (mirrors the lazy lightningcss backend). The
|
|
213
|
+
// `dart-sass` JS API is pure JS, so it loads under GJS + Node alike.
|
|
214
|
+
_sassPromise = import(/* @vite-ignore */ 'sass');
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
const sass = await _sassPromise;
|
|
218
|
+
return sass.compile(filename, { style: 'expanded' }).css;
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
throw new Error(`gjsify css-as-string: failed to compile Sass file ${filename}. ` +
|
|
222
|
+
`Is the \`sass\` package installed? (${err.message})`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
199
225
|
async function loadAndBundleCss(filename, targets) {
|
|
200
226
|
if (!_bundlerPromise)
|
|
201
227
|
_bundlerPromise = pickBundler();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/rolldown-plugin-gjsify",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -55,19 +55,20 @@
|
|
|
55
55
|
],
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@gjsify/console": "^0.16.
|
|
59
|
-
"@gjsify/resolve-npm": "^0.16.
|
|
60
|
-
"@gjsify/rolldown-plugin-deepkit": "^0.16.
|
|
61
|
-
"@gjsify/rolldown-plugin-pnp": "^0.16.
|
|
62
|
-
"@gjsify/vite-plugin-blueprint": "^0.16.
|
|
58
|
+
"@gjsify/console": "^0.16.3",
|
|
59
|
+
"@gjsify/resolve-npm": "^0.16.3",
|
|
60
|
+
"@gjsify/rolldown-plugin-deepkit": "^0.16.3",
|
|
61
|
+
"@gjsify/rolldown-plugin-pnp": "^0.16.3",
|
|
62
|
+
"@gjsify/vite-plugin-blueprint": "^0.16.3",
|
|
63
63
|
"@rollup/pluginutils": "^5.4.0",
|
|
64
64
|
"acorn": "^8.17.0",
|
|
65
65
|
"acorn-walk": "^8.3.5",
|
|
66
66
|
"fast-glob": "^3.3.3",
|
|
67
|
-
"lightningcss": "^1.32.0"
|
|
67
|
+
"lightningcss": "^1.32.0",
|
|
68
|
+
"sass": "^1.101.0"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
|
-
"@gjsify/lightningcss-native": "^0.16.
|
|
71
|
+
"@gjsify/lightningcss-native": "^0.16.3",
|
|
71
72
|
"rolldown": "^1.1.4"
|
|
72
73
|
},
|
|
73
74
|
"peerDependenciesMeta": {
|