neo.mjs 4.0.22 → 4.0.25
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.
|
@@ -318,76 +318,78 @@ if (programOpts.info) {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
files.forEach(file => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const plugins = [autoprefixer];
|
|
335
|
-
|
|
336
|
-
if (mode === 'production') {
|
|
337
|
-
plugins.push(cssnano);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
map = result.map?.toString();
|
|
321
|
+
if (file.path.endsWith('.scss')) {
|
|
322
|
+
addItemToThemeMap(file, target, useCssVars);
|
|
323
|
+
|
|
324
|
+
let folderPath = path.resolve(cwd, `dist/${mode}/css${suffix}/${target}/${file.relativePath}`),
|
|
325
|
+
destPath = path.resolve(folderPath, `${file.name}.css`);
|
|
326
|
+
|
|
327
|
+
fs.readFile(file.path).then(content => {
|
|
328
|
+
let result = sass.renderSync({
|
|
329
|
+
data : data + scssCombine(content.toString(), path.resolve(neoPath, scssPath, target, file.relativePath)),
|
|
330
|
+
outFile : destPath,
|
|
331
|
+
sourceMap : devMode,
|
|
332
|
+
sourceMapEmbed: false
|
|
333
|
+
});
|
|
341
334
|
|
|
342
|
-
|
|
343
|
-
// https://github.com/neomjs/neo/issues/1970
|
|
344
|
-
map = JSON.parse(map);
|
|
345
|
-
let len = file.relativePath.split('/').length,
|
|
346
|
-
src = `${target}${file.relativePath}/${file.name}.scss`,
|
|
347
|
-
i = 0;
|
|
335
|
+
const plugins = [autoprefixer];
|
|
348
336
|
|
|
349
|
-
|
|
350
|
-
|
|
337
|
+
if (mode === 'production') {
|
|
338
|
+
plugins.push(cssnano);
|
|
351
339
|
}
|
|
352
340
|
|
|
353
|
-
map
|
|
354
|
-
}
|
|
341
|
+
map = result.map?.toString();
|
|
355
342
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}).then(result => {
|
|
363
|
-
fs.mkdirpSync(folderPath);
|
|
364
|
-
fileCount[mode][varsFlag]++;
|
|
343
|
+
if (map) {
|
|
344
|
+
// https://github.com/neomjs/neo/issues/1970
|
|
345
|
+
map = JSON.parse(map);
|
|
346
|
+
let len = file.relativePath.split('/').length,
|
|
347
|
+
src = `${target}${file.relativePath}/${file.name}.scss`,
|
|
348
|
+
i = 0;
|
|
365
349
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
350
|
+
for (; i < len; i++) {
|
|
351
|
+
src = '../' + src;
|
|
352
|
+
}
|
|
369
353
|
|
|
370
|
-
|
|
371
|
-
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
|
|
354
|
+
map.sources = [src];
|
|
372
355
|
}
|
|
373
356
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
357
|
+
postcss(plugins).process(result.css, {
|
|
358
|
+
from: file.path,
|
|
359
|
+
to : destPath,
|
|
360
|
+
map : !devMode ? null : {
|
|
361
|
+
prev: map && JSON.stringify(map)
|
|
362
|
+
}
|
|
363
|
+
}).then(result => {
|
|
364
|
+
fs.mkdirpSync(folderPath);
|
|
365
|
+
fileCount[mode][varsFlag]++;
|
|
366
|
+
|
|
367
|
+
const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
|
|
368
|
+
console.log('Writing file:', (fileCount[mode].vars + fileCount[mode].noVars), chalk.blue(`${processTime}s`), destPath);
|
|
369
|
+
fs.writeFileSync(destPath, result.css, () => true);
|
|
370
|
+
|
|
371
|
+
if (result.map) {
|
|
372
|
+
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (fileCount[mode][varsFlag] === totalFiles[mode][varsFlag]) {
|
|
376
|
+
fs.writeFileSync(
|
|
377
|
+
path.resolve(cwd, useCssVars ? themeMapFile : themeMapFileNoVars),
|
|
378
|
+
JSON.stringify(useCssVars ? themeMap : themeMapNoVars, null, 0)
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
fs.mkdirpSync(path.join(cwd, '/dist/', mode, '/resources'), {
|
|
382
|
+
recursive: true
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
fs.writeFileSync(
|
|
386
|
+
path.join(cwd, '/dist/', mode, useCssVars ? themeMapFile : themeMapFileNoVars),
|
|
387
|
+
JSON.stringify(useCssVars ? themeMap : themeMapNoVars, null, 0)
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
389
391
|
});
|
|
390
|
-
}
|
|
392
|
+
}
|
|
391
393
|
});
|
|
392
394
|
}
|
|
393
395
|
|
package/package.json
CHANGED
|
@@ -60,11 +60,12 @@ class Stylesheet extends Base {
|
|
|
60
60
|
*
|
|
61
61
|
*/
|
|
62
62
|
addGlobalCss() {
|
|
63
|
-
let config
|
|
64
|
-
themes
|
|
65
|
-
folders
|
|
66
|
-
env
|
|
67
|
-
path
|
|
63
|
+
let config = Neo.config,
|
|
64
|
+
themes = config.themes,
|
|
65
|
+
folders = config.useCssVars ? ['src', ...themes] : [themes[0]],
|
|
66
|
+
env = config.environment,
|
|
67
|
+
path = env.startsWith('dist/') ? '' : `../../dist/${env}/`,
|
|
68
|
+
rootPath = config.basePath.substr(6);
|
|
68
69
|
|
|
69
70
|
document.body.classList.add(themes[0]);
|
|
70
71
|
|
|
@@ -76,7 +77,7 @@ class Stylesheet extends Base {
|
|
|
76
77
|
this.createStyleSheet(
|
|
77
78
|
null,
|
|
78
79
|
null,
|
|
79
|
-
`${
|
|
80
|
+
`${rootPath}${path}css${config.useCssVars ? '' : '-no-vars'}/${folder}/Global.css`
|
|
80
81
|
);
|
|
81
82
|
});
|
|
82
83
|
}
|
|
@@ -90,7 +91,8 @@ class Stylesheet extends Base {
|
|
|
90
91
|
let className = data.className,
|
|
91
92
|
config = Neo.config,
|
|
92
93
|
env = config.environment,
|
|
93
|
-
path = env.startsWith('dist/') ?
|
|
94
|
+
path = env.startsWith('dist/') ? '' : `../../dist/${env}/`,
|
|
95
|
+
rootPath = config.basePath.substr(6);
|
|
94
96
|
|
|
95
97
|
if (className.startsWith('Neo.')) {
|
|
96
98
|
className = className.substring(4);
|
|
@@ -108,7 +110,7 @@ class Stylesheet extends Base {
|
|
|
108
110
|
this.createStyleSheet(
|
|
109
111
|
null,
|
|
110
112
|
null,
|
|
111
|
-
`${
|
|
113
|
+
`${rootPath}${path}css${config.useCssVars ? '' : '-no-vars'}/${folder}/${className}.css`
|
|
112
114
|
);
|
|
113
115
|
}
|
|
114
116
|
});
|