sdc-build-wp 1.3.4 → 2.0.0
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/index.js +14 -1
- package/lib/style.js +23 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,7 +18,11 @@ let chokidarOpts = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
let sassGlobPath = project.package?.sdc?.sassGlobPath || project.path + '/_src/style/**/*.scss';
|
|
21
|
-
let sassGlob = glob.sync(sassGlobPath
|
|
21
|
+
let sassGlob = glob.sync(sassGlobPath, {
|
|
22
|
+
ignore: [
|
|
23
|
+
project.path + '/_src/style/partials/_colors.scss'
|
|
24
|
+
]
|
|
25
|
+
});
|
|
22
26
|
|
|
23
27
|
function bustFunctionsCache() {
|
|
24
28
|
bustCache(project.path + '/functions.php');
|
|
@@ -76,6 +80,15 @@ if (argv.watch) {
|
|
|
76
80
|
});
|
|
77
81
|
});
|
|
78
82
|
}
|
|
83
|
+
if (argv.watch) {
|
|
84
|
+
chokidar.watch(project.path + '/theme.json', chokidarOpts).on('all', (event, path) => {
|
|
85
|
+
filesSass.forEach((file) => {
|
|
86
|
+
buildSass(file, sassGlob);
|
|
87
|
+
bustFunctionsCache();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
frontrunImages()
|
|
80
93
|
if (argv.watch) {
|
|
81
94
|
chokidar.watch(project.path + '/_src/images/**/*', chokidarOpts).on('all', (event, path) => {
|
package/lib/style.js
CHANGED
|
@@ -8,8 +8,30 @@ import postcss from 'postcss';
|
|
|
8
8
|
import autoprefixer from 'autoprefixer';
|
|
9
9
|
import sortMQ from 'postcss-sort-media-queries';
|
|
10
10
|
import stylelint from 'stylelint';
|
|
11
|
+
import { promises } from 'fs';
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const buildColors = async () => {
|
|
14
|
+
try {
|
|
15
|
+
let theme = JSON.parse(await promises.readFile(project.path + '/theme.json'));
|
|
16
|
+
if (theme.settings?.color?.palette?.length > 0) {
|
|
17
|
+
let palette = theme.settings.color.palette;
|
|
18
|
+
let colorFileData = `// This file is automatically generated. Do not edit.\n`;
|
|
19
|
+
for (var color of palette) {
|
|
20
|
+
colorFileData += `$${color['slug']}: ${color['color']};\n`;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
await promises.writeFile(project.path + '/_src/style/partials/_colors.scss', colorFileData);
|
|
24
|
+
} catch {
|
|
25
|
+
log('error', `Failed to read write colors.scss - See above error.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
log('error', `Failed to read theme.json - See above error.`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const buildSass = async (entry, entriesToLint) => {
|
|
34
|
+
await buildColors();
|
|
13
35
|
let timerStart = Date.now();
|
|
14
36
|
let outFile = project.path + '/dist/style/' + path.parse(entry).name + '.min.css';
|
|
15
37
|
let entryLabel = outFile.replace(project.path, '');
|