vite-plugin-qingkuai 1.0.16 → 1.0.17
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/index.cjs +29 -1
- package/dist/index.js +30 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,16 @@ var selectorParser = require('postcss-selector-parser');
|
|
|
11
11
|
var vite = require('vite');
|
|
12
12
|
var sourceMapJs = require('source-map-js');
|
|
13
13
|
|
|
14
|
+
const globalStyle = "\n" + compiler.util.formatSourceCode(
|
|
15
|
+
`
|
|
16
|
+
/* Injected by vite-plugin-qingkuai */
|
|
17
|
+
|
|
18
|
+
*[hidden]{
|
|
19
|
+
display: none !important;
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
).replace(/^/gm, " ") + "\n";
|
|
23
|
+
|
|
14
24
|
function isUndefined(v) {
|
|
15
25
|
return void 0 === v;
|
|
16
26
|
}
|
|
@@ -137,6 +147,18 @@ function qingkuai() {
|
|
|
137
147
|
}
|
|
138
148
|
loadAllQingkuaiConfigurations(config.root);
|
|
139
149
|
},
|
|
150
|
+
transformIndexHtml(html) {
|
|
151
|
+
return {
|
|
152
|
+
html,
|
|
153
|
+
tags: [
|
|
154
|
+
{
|
|
155
|
+
tag: "style",
|
|
156
|
+
injectTo: "head",
|
|
157
|
+
children: globalStyle
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
};
|
|
161
|
+
},
|
|
140
162
|
resolveId(id, importer) {
|
|
141
163
|
if (styleIdRE.test(id)) {
|
|
142
164
|
return id;
|
|
@@ -291,7 +313,13 @@ function qingkuai() {
|
|
|
291
313
|
})
|
|
292
314
|
};
|
|
293
315
|
} catch (err) {
|
|
294
|
-
err.
|
|
316
|
+
if (err.loc.start && "index" in err.loc.start) {
|
|
317
|
+
err.pos = err.loc.start.index, this.error(err);
|
|
318
|
+
} else {
|
|
319
|
+
this.error(
|
|
320
|
+
"Qingkuai compile result is invalid. Please report this at https://github.com/qingkuai-js/qingkuai/issues and include your .qk source for reproduction."
|
|
321
|
+
);
|
|
322
|
+
}
|
|
295
323
|
}
|
|
296
324
|
}
|
|
297
325
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import nodePath from 'node:path';
|
|
2
2
|
import nodeCrypto from 'node:crypto';
|
|
3
|
-
import { compile } from 'qingkuai/compiler';
|
|
3
|
+
import { util, compile } from 'qingkuai/compiler';
|
|
4
4
|
import nodeFs, { existsSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { LinesAndColumns } from 'lines-and-columns';
|
|
6
6
|
import { decode, encode } from '@jridgewell/sourcemap-codec';
|
|
@@ -9,6 +9,16 @@ import selectorParser from 'postcss-selector-parser';
|
|
|
9
9
|
import { transformWithEsbuild, preprocessCSS } from 'vite';
|
|
10
10
|
import { SourceMapConsumer } from 'source-map-js';
|
|
11
11
|
|
|
12
|
+
const globalStyle = "\n" + util.formatSourceCode(
|
|
13
|
+
`
|
|
14
|
+
/* Injected by vite-plugin-qingkuai */
|
|
15
|
+
|
|
16
|
+
*[hidden]{
|
|
17
|
+
display: none !important;
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
).replace(/^/gm, " ") + "\n";
|
|
21
|
+
|
|
12
22
|
function isUndefined(v) {
|
|
13
23
|
return void 0 === v;
|
|
14
24
|
}
|
|
@@ -135,6 +145,18 @@ function qingkuai() {
|
|
|
135
145
|
}
|
|
136
146
|
loadAllQingkuaiConfigurations(config.root);
|
|
137
147
|
},
|
|
148
|
+
transformIndexHtml(html) {
|
|
149
|
+
return {
|
|
150
|
+
html,
|
|
151
|
+
tags: [
|
|
152
|
+
{
|
|
153
|
+
tag: "style",
|
|
154
|
+
injectTo: "head",
|
|
155
|
+
children: globalStyle
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
},
|
|
138
160
|
resolveId(id, importer) {
|
|
139
161
|
if (styleIdRE.test(id)) {
|
|
140
162
|
return id;
|
|
@@ -289,7 +311,13 @@ function qingkuai() {
|
|
|
289
311
|
})
|
|
290
312
|
};
|
|
291
313
|
} catch (err) {
|
|
292
|
-
err.
|
|
314
|
+
if (err.loc.start && "index" in err.loc.start) {
|
|
315
|
+
err.pos = err.loc.start.index, this.error(err);
|
|
316
|
+
} else {
|
|
317
|
+
this.error(
|
|
318
|
+
"Qingkuai compile result is invalid. Please report this at https://github.com/qingkuai-js/qingkuai/issues and include your .qk source for reproduction."
|
|
319
|
+
);
|
|
320
|
+
}
|
|
293
321
|
}
|
|
294
322
|
}
|
|
295
323
|
};
|