vite-plugin-qingkuai 1.0.12 → 1.0.13
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/.vscode/extensions.json +3 -0
- package/dist/index.cjs +80 -44
- package/dist/index.js +79 -43
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var node_crypto = require('node:crypto');
|
|
3
|
+
var nodePath = require('node:path');
|
|
4
|
+
var nodeCrypto = require('node:crypto');
|
|
6
5
|
var compiler = require('qingkuai/compiler');
|
|
6
|
+
var nodeFs = require('node:fs');
|
|
7
7
|
var linesAndColumns = require('lines-and-columns');
|
|
8
8
|
var sourcemapCodec = require('@jridgewell/sourcemap-codec');
|
|
9
9
|
var postcss = require('postcss');
|
|
@@ -11,14 +11,17 @@ var selectorParser = require('postcss-selector-parser');
|
|
|
11
11
|
var vite = require('vite');
|
|
12
12
|
var sourceMapJs = require('source-map-js');
|
|
13
13
|
|
|
14
|
+
function isUndefined(v) {
|
|
15
|
+
return void 0 === v;
|
|
16
|
+
}
|
|
14
17
|
function findFilesByName(dir, targetFileName, ignoreList) {
|
|
15
18
|
const result = [];
|
|
16
|
-
const entries =
|
|
19
|
+
const entries = nodeFs.readdirSync(dir, { withFileTypes: true });
|
|
17
20
|
for (const entry of entries) {
|
|
18
21
|
if (ignoreList.has(entry.name)) {
|
|
19
22
|
continue;
|
|
20
23
|
}
|
|
21
|
-
const fullPath =
|
|
24
|
+
const fullPath = nodePath.join(dir, entry.name);
|
|
22
25
|
if (entry.name === targetFileName) {
|
|
23
26
|
result.push(fullPath);
|
|
24
27
|
} else if (entry.isDirectory()) {
|
|
@@ -105,16 +108,8 @@ function qingkuai() {
|
|
|
105
108
|
const styleIdRE = /^virtual:\[\d+\].*?\.qk.(?:css|s[ac]ss|less|stylus|postcss)\?\d{13}$/;
|
|
106
109
|
return {
|
|
107
110
|
name: "qingkuai-compiler",
|
|
108
|
-
config(
|
|
109
|
-
const rootPath = path.resolve(process.cwd(), config.root ?? "");
|
|
110
|
-
const qingkuaiConfig = getQingkuaiConfiguration(rootPath);
|
|
111
|
+
config(_, env) {
|
|
111
112
|
isDev = env.command === "serve";
|
|
112
|
-
return {
|
|
113
|
-
define: {
|
|
114
|
-
__qk_expose_dependencies__: JSON.stringify(!!qingkuaiConfig.exposeDependencies),
|
|
115
|
-
__qk_expose_destructions__: JSON.stringify(!!qingkuaiConfig.exposeDestructions)
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
113
|
},
|
|
119
114
|
configureServer(server) {
|
|
120
115
|
createQingkuaiConfigurationWatcher(server);
|
|
@@ -128,15 +123,30 @@ function qingkuai() {
|
|
|
128
123
|
cssSourcemap = true;
|
|
129
124
|
sourcemap = config.build.sourcemap !== false;
|
|
130
125
|
}
|
|
126
|
+
const optimizeDeps = config.optimizeDeps;
|
|
127
|
+
if (!optimizeDeps) {
|
|
128
|
+
Object.assign(config, {
|
|
129
|
+
optimizeDeps: {
|
|
130
|
+
exclude: ["qingkuai"]
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
} else if (!optimizeDeps.exclude) {
|
|
134
|
+
optimizeDeps.exclude = ["qingkuai"];
|
|
135
|
+
} else {
|
|
136
|
+
optimizeDeps.exclude.push("qingkuai");
|
|
137
|
+
}
|
|
131
138
|
loadAllQingkuaiConfigurations(config.root);
|
|
132
139
|
},
|
|
133
140
|
resolveId(id, importer) {
|
|
134
141
|
if (styleIdRE.test(id)) {
|
|
135
142
|
return id;
|
|
136
143
|
}
|
|
137
|
-
if (importer?.endsWith(".qk") && !
|
|
144
|
+
if (importer?.endsWith(".qk") && !nodePath.extname(id)) {
|
|
138
145
|
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
139
|
-
return
|
|
146
|
+
return nodePath.join(
|
|
147
|
+
nodePath.dirname(importer),
|
|
148
|
+
id + (qingkuaiConfig.resolveImportExtension ? ".qk" : "")
|
|
149
|
+
);
|
|
140
150
|
}
|
|
141
151
|
return id;
|
|
142
152
|
},
|
|
@@ -148,11 +158,11 @@ function qingkuai() {
|
|
|
148
158
|
}
|
|
149
159
|
let virtualFileName;
|
|
150
160
|
const compileRes = compileResultCache.get(fileId);
|
|
151
|
-
const style = compileRes.
|
|
161
|
+
const style = compileRes.styleDescriptors[index];
|
|
152
162
|
while (true) {
|
|
153
|
-
const hash =
|
|
163
|
+
const hash = nodeCrypto.randomBytes(6).toString("hex");
|
|
154
164
|
virtualFileName = `${fileId}.${hash}.${style.lang}`;
|
|
155
|
-
if (!
|
|
165
|
+
if (!nodeFs.existsSync(virtualFileName)) {
|
|
156
166
|
break;
|
|
157
167
|
}
|
|
158
168
|
}
|
|
@@ -196,7 +206,7 @@ function qingkuai() {
|
|
|
196
206
|
line: preprocessedPosition.line - 1,
|
|
197
207
|
column: preprocessedPosition.column
|
|
198
208
|
}) || 0;
|
|
199
|
-
const position = compileRes.
|
|
209
|
+
const position = compileRes.positions[style.loc.start.index + preprocessedIndex];
|
|
200
210
|
this.error({
|
|
201
211
|
message: attachScopeResult.error.message,
|
|
202
212
|
loc: {
|
|
@@ -224,11 +234,11 @@ function qingkuai() {
|
|
|
224
234
|
}
|
|
225
235
|
try {
|
|
226
236
|
const compileRes = compiler.compile(src, {
|
|
237
|
+
...getCompileOptions(id),
|
|
227
238
|
sourcemap,
|
|
228
239
|
debug: isDev,
|
|
229
|
-
hashId: compileResultCache.get(id)?.hashId
|
|
230
|
-
componentName: compiler.util.kebab2Camel(
|
|
231
|
-
reserveTemplateComment: getReserveHtmlComments(getQingkuaiConfiguration(id))
|
|
240
|
+
hashId: compileResultCache.get(id)?.hashId,
|
|
241
|
+
componentName: compiler.util.kebab2Camel(nodePath.basename(id, nodePath.extname(id)), true)
|
|
232
242
|
});
|
|
233
243
|
compileRes.messages.forEach(({ type, value: warning }) => {
|
|
234
244
|
if (type === "warning") {
|
|
@@ -237,7 +247,7 @@ function qingkuai() {
|
|
|
237
247
|
});
|
|
238
248
|
compileResultCache.set(id, compileRes);
|
|
239
249
|
const compiledCodeArr = [compileRes.code];
|
|
240
|
-
compileRes.
|
|
250
|
+
compileRes.styleDescriptors.forEach((_, index) => {
|
|
241
251
|
compiledCodeArr.push(`import "virtual:[${index}]${id}.css?${Date.now()}"`);
|
|
242
252
|
});
|
|
243
253
|
const baseMap = {
|
|
@@ -246,7 +256,7 @@ function qingkuai() {
|
|
|
246
256
|
sourcesContent: [src]
|
|
247
257
|
};
|
|
248
258
|
const compiledCode = compiledCodeArr.join("\n");
|
|
249
|
-
if (!compileRes.
|
|
259
|
+
if (!compileRes.scriptDescriptor.isTS) {
|
|
250
260
|
if (!sourcemap) {
|
|
251
261
|
return compiledCode;
|
|
252
262
|
}
|
|
@@ -288,14 +298,12 @@ function qingkuai() {
|
|
|
288
298
|
};
|
|
289
299
|
function getQingkuaiConfiguration(id) {
|
|
290
300
|
let config = {
|
|
291
|
-
|
|
292
|
-
exposeDestructions: isDev,
|
|
293
|
-
exposeDependencies: isDev,
|
|
301
|
+
interpretiveComments: true,
|
|
294
302
|
resolveImportExtension: true,
|
|
295
|
-
|
|
303
|
+
preserveHtmlComments: "development"
|
|
296
304
|
};
|
|
297
305
|
while (true) {
|
|
298
|
-
const dir =
|
|
306
|
+
const dir = nodePath.dirname(id);
|
|
299
307
|
if (dir === id) {
|
|
300
308
|
break;
|
|
301
309
|
}
|
|
@@ -307,21 +315,9 @@ function qingkuai() {
|
|
|
307
315
|
}
|
|
308
316
|
return config;
|
|
309
317
|
}
|
|
310
|
-
function getReserveHtmlComments(config) {
|
|
311
|
-
switch (config.reserveHtmlComments) {
|
|
312
|
-
case "all":
|
|
313
|
-
return true;
|
|
314
|
-
case "never":
|
|
315
|
-
return false;
|
|
316
|
-
case "production":
|
|
317
|
-
return !isDev;
|
|
318
|
-
default:
|
|
319
|
-
return isDev;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
318
|
function createQingkuaiConfigurationWatcher(server) {
|
|
323
319
|
const watcher = server.watcher.add([".qingkuairc", "!**/node_modules/**"]);
|
|
324
|
-
watcher.on("unlink", (p) => qingkuaiConfigurations.delete(
|
|
320
|
+
watcher.on("unlink", (p) => qingkuaiConfigurations.delete(nodePath.dirname(p)));
|
|
325
321
|
watcher.on("change", recordQingkuaiConfiguration);
|
|
326
322
|
watcher.on("add", recordQingkuaiConfiguration);
|
|
327
323
|
}
|
|
@@ -332,10 +328,50 @@ function qingkuai() {
|
|
|
332
328
|
}
|
|
333
329
|
function recordQingkuaiConfiguration(fileName) {
|
|
334
330
|
try {
|
|
335
|
-
qingkuaiConfigurations.set(
|
|
331
|
+
qingkuaiConfigurations.set(nodePath.dirname(fileName), JSON.parse(nodeFs.readFileSync(fileName, "utf-8")));
|
|
336
332
|
} catch {
|
|
337
333
|
}
|
|
338
334
|
}
|
|
335
|
+
function getCompileOptions(id) {
|
|
336
|
+
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
337
|
+
const ret = {
|
|
338
|
+
interpretiveComments: isUndefined(qingkuaiConfig.interpretiveComments) ? isDev : !!qingkuaiConfig.interpretiveComments,
|
|
339
|
+
shorthandDerivedDeclaration: isUndefined(qingkuaiConfig.shorthandDerivedDeclaration) ? true : !!qingkuaiConfig.shorthandDerivedDeclaration,
|
|
340
|
+
reactivityMode: qingkuaiConfig.reactivityMode === "shallow" ? "shallow" : "reactive"
|
|
341
|
+
};
|
|
342
|
+
switch (qingkuaiConfig.whitespace) {
|
|
343
|
+
case "trim":
|
|
344
|
+
case "collapse":
|
|
345
|
+
case "preserve":
|
|
346
|
+
case "trim-collapse": {
|
|
347
|
+
ret.whitespace = qingkuaiConfig.whitespace;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
default: {
|
|
351
|
+
ret.whitespace = "trim-collapse";
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
switch (qingkuaiConfig.preserveHtmlComments) {
|
|
356
|
+
case "all": {
|
|
357
|
+
ret.preserveHtmlComments = true;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "never": {
|
|
361
|
+
ret.preserveHtmlComments = false;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case "production": {
|
|
365
|
+
ret.preserveHtmlComments = !isDev;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
default: {
|
|
369
|
+
ret.preserveHtmlComments = isDev;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return ret;
|
|
374
|
+
}
|
|
339
375
|
}
|
|
340
376
|
function parseStyleId(id) {
|
|
341
377
|
const m1 = /^virtual:\[(\d+)\]/.exec(id);
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { randomBytes } from 'node:crypto';
|
|
1
|
+
import nodePath from 'node:path';
|
|
2
|
+
import nodeCrypto from 'node:crypto';
|
|
4
3
|
import { compile, util } from 'qingkuai/compiler';
|
|
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';
|
|
7
7
|
import postcss from 'postcss';
|
|
@@ -9,14 +9,17 @@ import selectorParser from 'postcss-selector-parser';
|
|
|
9
9
|
import { transformWithEsbuild, preprocessCSS } from 'vite';
|
|
10
10
|
import { SourceMapConsumer } from 'source-map-js';
|
|
11
11
|
|
|
12
|
+
function isUndefined(v) {
|
|
13
|
+
return void 0 === v;
|
|
14
|
+
}
|
|
12
15
|
function findFilesByName(dir, targetFileName, ignoreList) {
|
|
13
16
|
const result = [];
|
|
14
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
17
|
+
const entries = nodeFs.readdirSync(dir, { withFileTypes: true });
|
|
15
18
|
for (const entry of entries) {
|
|
16
19
|
if (ignoreList.has(entry.name)) {
|
|
17
20
|
continue;
|
|
18
21
|
}
|
|
19
|
-
const fullPath = join(dir, entry.name);
|
|
22
|
+
const fullPath = nodePath.join(dir, entry.name);
|
|
20
23
|
if (entry.name === targetFileName) {
|
|
21
24
|
result.push(fullPath);
|
|
22
25
|
} else if (entry.isDirectory()) {
|
|
@@ -103,16 +106,8 @@ function qingkuai() {
|
|
|
103
106
|
const styleIdRE = /^virtual:\[\d+\].*?\.qk.(?:css|s[ac]ss|less|stylus|postcss)\?\d{13}$/;
|
|
104
107
|
return {
|
|
105
108
|
name: "qingkuai-compiler",
|
|
106
|
-
config(
|
|
107
|
-
const rootPath = path.resolve(process.cwd(), config.root ?? "");
|
|
108
|
-
const qingkuaiConfig = getQingkuaiConfiguration(rootPath);
|
|
109
|
+
config(_, env) {
|
|
109
110
|
isDev = env.command === "serve";
|
|
110
|
-
return {
|
|
111
|
-
define: {
|
|
112
|
-
__qk_expose_dependencies__: JSON.stringify(!!qingkuaiConfig.exposeDependencies),
|
|
113
|
-
__qk_expose_destructions__: JSON.stringify(!!qingkuaiConfig.exposeDestructions)
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
111
|
},
|
|
117
112
|
configureServer(server) {
|
|
118
113
|
createQingkuaiConfigurationWatcher(server);
|
|
@@ -126,15 +121,30 @@ function qingkuai() {
|
|
|
126
121
|
cssSourcemap = true;
|
|
127
122
|
sourcemap = config.build.sourcemap !== false;
|
|
128
123
|
}
|
|
124
|
+
const optimizeDeps = config.optimizeDeps;
|
|
125
|
+
if (!optimizeDeps) {
|
|
126
|
+
Object.assign(config, {
|
|
127
|
+
optimizeDeps: {
|
|
128
|
+
exclude: ["qingkuai"]
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
} else if (!optimizeDeps.exclude) {
|
|
132
|
+
optimizeDeps.exclude = ["qingkuai"];
|
|
133
|
+
} else {
|
|
134
|
+
optimizeDeps.exclude.push("qingkuai");
|
|
135
|
+
}
|
|
129
136
|
loadAllQingkuaiConfigurations(config.root);
|
|
130
137
|
},
|
|
131
138
|
resolveId(id, importer) {
|
|
132
139
|
if (styleIdRE.test(id)) {
|
|
133
140
|
return id;
|
|
134
141
|
}
|
|
135
|
-
if (importer?.endsWith(".qk") && !
|
|
142
|
+
if (importer?.endsWith(".qk") && !nodePath.extname(id)) {
|
|
136
143
|
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
137
|
-
return
|
|
144
|
+
return nodePath.join(
|
|
145
|
+
nodePath.dirname(importer),
|
|
146
|
+
id + (qingkuaiConfig.resolveImportExtension ? ".qk" : "")
|
|
147
|
+
);
|
|
138
148
|
}
|
|
139
149
|
return id;
|
|
140
150
|
},
|
|
@@ -146,9 +156,9 @@ function qingkuai() {
|
|
|
146
156
|
}
|
|
147
157
|
let virtualFileName;
|
|
148
158
|
const compileRes = compileResultCache.get(fileId);
|
|
149
|
-
const style = compileRes.
|
|
159
|
+
const style = compileRes.styleDescriptors[index];
|
|
150
160
|
while (true) {
|
|
151
|
-
const hash = randomBytes(6).toString("hex");
|
|
161
|
+
const hash = nodeCrypto.randomBytes(6).toString("hex");
|
|
152
162
|
virtualFileName = `${fileId}.${hash}.${style.lang}`;
|
|
153
163
|
if (!existsSync(virtualFileName)) {
|
|
154
164
|
break;
|
|
@@ -194,7 +204,7 @@ function qingkuai() {
|
|
|
194
204
|
line: preprocessedPosition.line - 1,
|
|
195
205
|
column: preprocessedPosition.column
|
|
196
206
|
}) || 0;
|
|
197
|
-
const position = compileRes.
|
|
207
|
+
const position = compileRes.positions[style.loc.start.index + preprocessedIndex];
|
|
198
208
|
this.error({
|
|
199
209
|
message: attachScopeResult.error.message,
|
|
200
210
|
loc: {
|
|
@@ -222,11 +232,11 @@ function qingkuai() {
|
|
|
222
232
|
}
|
|
223
233
|
try {
|
|
224
234
|
const compileRes = compile(src, {
|
|
235
|
+
...getCompileOptions(id),
|
|
225
236
|
sourcemap,
|
|
226
237
|
debug: isDev,
|
|
227
|
-
hashId: compileResultCache.get(id)?.hashId
|
|
228
|
-
componentName: util.kebab2Camel(
|
|
229
|
-
reserveTemplateComment: getReserveHtmlComments(getQingkuaiConfiguration(id))
|
|
238
|
+
hashId: compileResultCache.get(id)?.hashId,
|
|
239
|
+
componentName: util.kebab2Camel(nodePath.basename(id, nodePath.extname(id)), true)
|
|
230
240
|
});
|
|
231
241
|
compileRes.messages.forEach(({ type, value: warning }) => {
|
|
232
242
|
if (type === "warning") {
|
|
@@ -235,7 +245,7 @@ function qingkuai() {
|
|
|
235
245
|
});
|
|
236
246
|
compileResultCache.set(id, compileRes);
|
|
237
247
|
const compiledCodeArr = [compileRes.code];
|
|
238
|
-
compileRes.
|
|
248
|
+
compileRes.styleDescriptors.forEach((_, index) => {
|
|
239
249
|
compiledCodeArr.push(`import "virtual:[${index}]${id}.css?${Date.now()}"`);
|
|
240
250
|
});
|
|
241
251
|
const baseMap = {
|
|
@@ -244,7 +254,7 @@ function qingkuai() {
|
|
|
244
254
|
sourcesContent: [src]
|
|
245
255
|
};
|
|
246
256
|
const compiledCode = compiledCodeArr.join("\n");
|
|
247
|
-
if (!compileRes.
|
|
257
|
+
if (!compileRes.scriptDescriptor.isTS) {
|
|
248
258
|
if (!sourcemap) {
|
|
249
259
|
return compiledCode;
|
|
250
260
|
}
|
|
@@ -286,14 +296,12 @@ function qingkuai() {
|
|
|
286
296
|
};
|
|
287
297
|
function getQingkuaiConfiguration(id) {
|
|
288
298
|
let config = {
|
|
289
|
-
|
|
290
|
-
exposeDestructions: isDev,
|
|
291
|
-
exposeDependencies: isDev,
|
|
299
|
+
interpretiveComments: true,
|
|
292
300
|
resolveImportExtension: true,
|
|
293
|
-
|
|
301
|
+
preserveHtmlComments: "development"
|
|
294
302
|
};
|
|
295
303
|
while (true) {
|
|
296
|
-
const dir =
|
|
304
|
+
const dir = nodePath.dirname(id);
|
|
297
305
|
if (dir === id) {
|
|
298
306
|
break;
|
|
299
307
|
}
|
|
@@ -305,21 +313,9 @@ function qingkuai() {
|
|
|
305
313
|
}
|
|
306
314
|
return config;
|
|
307
315
|
}
|
|
308
|
-
function getReserveHtmlComments(config) {
|
|
309
|
-
switch (config.reserveHtmlComments) {
|
|
310
|
-
case "all":
|
|
311
|
-
return true;
|
|
312
|
-
case "never":
|
|
313
|
-
return false;
|
|
314
|
-
case "production":
|
|
315
|
-
return !isDev;
|
|
316
|
-
default:
|
|
317
|
-
return isDev;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
316
|
function createQingkuaiConfigurationWatcher(server) {
|
|
321
317
|
const watcher = server.watcher.add([".qingkuairc", "!**/node_modules/**"]);
|
|
322
|
-
watcher.on("unlink", (p) => qingkuaiConfigurations.delete(
|
|
318
|
+
watcher.on("unlink", (p) => qingkuaiConfigurations.delete(nodePath.dirname(p)));
|
|
323
319
|
watcher.on("change", recordQingkuaiConfiguration);
|
|
324
320
|
watcher.on("add", recordQingkuaiConfiguration);
|
|
325
321
|
}
|
|
@@ -330,10 +326,50 @@ function qingkuai() {
|
|
|
330
326
|
}
|
|
331
327
|
function recordQingkuaiConfiguration(fileName) {
|
|
332
328
|
try {
|
|
333
|
-
qingkuaiConfigurations.set(
|
|
329
|
+
qingkuaiConfigurations.set(nodePath.dirname(fileName), JSON.parse(readFileSync(fileName, "utf-8")));
|
|
334
330
|
} catch {
|
|
335
331
|
}
|
|
336
332
|
}
|
|
333
|
+
function getCompileOptions(id) {
|
|
334
|
+
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
335
|
+
const ret = {
|
|
336
|
+
interpretiveComments: isUndefined(qingkuaiConfig.interpretiveComments) ? isDev : !!qingkuaiConfig.interpretiveComments,
|
|
337
|
+
shorthandDerivedDeclaration: isUndefined(qingkuaiConfig.shorthandDerivedDeclaration) ? true : !!qingkuaiConfig.shorthandDerivedDeclaration,
|
|
338
|
+
reactivityMode: qingkuaiConfig.reactivityMode === "shallow" ? "shallow" : "reactive"
|
|
339
|
+
};
|
|
340
|
+
switch (qingkuaiConfig.whitespace) {
|
|
341
|
+
case "trim":
|
|
342
|
+
case "collapse":
|
|
343
|
+
case "preserve":
|
|
344
|
+
case "trim-collapse": {
|
|
345
|
+
ret.whitespace = qingkuaiConfig.whitespace;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
default: {
|
|
349
|
+
ret.whitespace = "trim-collapse";
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
switch (qingkuaiConfig.preserveHtmlComments) {
|
|
354
|
+
case "all": {
|
|
355
|
+
ret.preserveHtmlComments = true;
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
case "never": {
|
|
359
|
+
ret.preserveHtmlComments = false;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case "production": {
|
|
363
|
+
ret.preserveHtmlComments = !isDev;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
default: {
|
|
367
|
+
ret.preserveHtmlComments = isDev;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return ret;
|
|
372
|
+
}
|
|
337
373
|
}
|
|
338
374
|
function parseStyleId(id) {
|
|
339
375
|
const m1 = /^virtual:\[(\d+)\]/.exec(id);
|