sdc-build-wp 2.6.1 → 2.7.1
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 +24 -8
- package/lib/bustCache.js +1 -0
- package/lib/scripts.js +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,6 +24,10 @@ let sassGlob = glob.sync(sassGlobPath, {
|
|
|
24
24
|
project.path + '/_src/style/partials/_theme.scss'
|
|
25
25
|
]
|
|
26
26
|
});
|
|
27
|
+
let jsGlobPath = project.package?.sdc?.jsGlobPath || project.path + '/_src/scripts/**/*.js';
|
|
28
|
+
let jsGlob = glob.sync(jsGlobPath, {
|
|
29
|
+
ignore: []
|
|
30
|
+
});
|
|
27
31
|
let blockGlobPath = project.package?.sdc?.blockGlobPath || project.path + '/_src/blocks/**/*.{js,jsx}';
|
|
28
32
|
let blockGlob = glob.sync(blockGlobPath);
|
|
29
33
|
|
|
@@ -54,6 +58,7 @@ for (var filename of sassBlocksGlob) {
|
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
let filesSass = [];
|
|
61
|
+
let filesJS = [];
|
|
57
62
|
|
|
58
63
|
for (const [name, files] of Object.entries(entries)) {
|
|
59
64
|
files.forEach(function(file) {
|
|
@@ -65,14 +70,10 @@ for (const [name, files] of Object.entries(entries)) {
|
|
|
65
70
|
});
|
|
66
71
|
break;
|
|
67
72
|
case '.js':
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
buildJS(path);
|
|
73
|
-
bustFunctionsCache();
|
|
74
|
-
});
|
|
75
|
-
}
|
|
73
|
+
filesJS.push({
|
|
74
|
+
'name': name,
|
|
75
|
+
'file': file
|
|
76
|
+
});
|
|
76
77
|
break;
|
|
77
78
|
}
|
|
78
79
|
});
|
|
@@ -100,6 +101,21 @@ if (argv.watch) {
|
|
|
100
101
|
runSass();
|
|
101
102
|
});
|
|
102
103
|
}
|
|
104
|
+
|
|
105
|
+
function runJS() {
|
|
106
|
+
for (var block of filesJS) {
|
|
107
|
+
buildJS(block.file, block.name, jsGlob);
|
|
108
|
+
bustFunctionsCache();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
runJS();
|
|
113
|
+
if (argv.watch) {
|
|
114
|
+
chokidar.watch(jsGlob, chokidarOpts).on('all', (event, path) => {
|
|
115
|
+
runJS();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
103
119
|
if (argv.watch) {
|
|
104
120
|
chokidar.watch(project.path + '/theme.json', chokidarOpts).on('all', (event, path) => {
|
|
105
121
|
runSass();
|
package/lib/bustCache.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
const bustCache = (file) => {
|
|
4
4
|
fs.readFile(file, 'utf8', function (err, data) {
|
|
5
5
|
if (err) { return console.log(err); }
|
|
6
|
+
if (!data.includes('$cacheVersion')) { return; }
|
|
6
7
|
var result = data.replace(/(\$cacheVersion\ \=\ \')(.*)(\'\;)/g, "$1" + new Date().getTime() + "$3");
|
|
7
8
|
fs.writeFile(file, result, 'utf8', function (err) {
|
|
8
9
|
if (err) return console.log(err);
|
package/lib/scripts.js
CHANGED
|
@@ -5,7 +5,7 @@ import esbuild from 'esbuild';
|
|
|
5
5
|
import { ESLint } from 'eslint';
|
|
6
6
|
import { readFile } from 'fs/promises';
|
|
7
7
|
|
|
8
|
-
const buildJS = async (entry) => {
|
|
8
|
+
const buildJS = async (entry, name, entriesToLint) => {
|
|
9
9
|
let entryLabel = `/dist/scripts/${path.parse(entry).base.replace('.js', '.min.js')}`;
|
|
10
10
|
let timerStart = Date.now();
|
|
11
11
|
try {
|
|
@@ -13,7 +13,7 @@ const buildJS = async (entry) => {
|
|
|
13
13
|
baseConfig: JSON.parse(await readFile(new URL('../.eslintrc', import.meta.url))),
|
|
14
14
|
fix: true
|
|
15
15
|
});
|
|
16
|
-
const lintresults = await eslint.lintFiles([entry]);
|
|
16
|
+
const lintresults = await eslint.lintFiles(entriesToLint || [entry]);
|
|
17
17
|
await ESLint.outputFixes(lintresults);
|
|
18
18
|
const formatter = await eslint.loadFormatter('stylish');
|
|
19
19
|
const formatterOutput = formatter.format(lintresults);
|