mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-27 00:30:09 +02:00
fix acss config with unquoted keys
This commit is contained in:
@@ -132,10 +132,18 @@ export function computeCss(userCode, mode, settings) {
|
|||||||
const html = code;
|
const html = code;
|
||||||
const foundClasses = atomizer.findClassNames(html);
|
const foundClasses = atomizer.findClassNames(html);
|
||||||
var finalConfig;
|
var finalConfig;
|
||||||
|
|
||||||
|
// Regular expression to find unquoted keys: looks for word characters (including _) followed by a colon
|
||||||
|
// and put them in quotes
|
||||||
|
const fixedConfigJson = (settings.acssConfig || '{}').replace(
|
||||||
|
/([{,]\s*)([^\s"{:]+)(\s*:\s*)/g,
|
||||||
|
'$1"$2"$3'
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
finalConfig = atomizer.getConfig(
|
finalConfig = atomizer.getConfig(
|
||||||
foundClasses,
|
foundClasses,
|
||||||
JSON.parse(settings.acssConfig)
|
JSON.parse(fixedConfigJson)
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
finalConfig = atomizer.getConfig(foundClasses, {});
|
finalConfig = atomizer.getConfig(foundClasses, {});
|
||||||
|
Reference in New Issue
Block a user