sdc-build-wp 3.2.4 → 3.3.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 +12 -10
- package/lib/images.js +4 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import project from './lib/project.js';
|
|
|
4
4
|
import parseArgs from 'minimist';
|
|
5
5
|
const argv = parseArgs(process.argv.slice(2));
|
|
6
6
|
import chokidar from 'chokidar';
|
|
7
|
-
import { glob } from 'glob';
|
|
7
|
+
import { glob, globSync } from 'glob';
|
|
8
8
|
|
|
9
9
|
import bustCache from './lib/bustCache.js';
|
|
10
10
|
import { buildSass, buildSassTheme } from './lib/style.js';
|
|
@@ -22,28 +22,30 @@ let chokidarOpts = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
let sassGlobPath = project.package?.sdc?.sassGlobPath || project.path + '{/_src/style,/blocks}/**/*.scss';
|
|
25
|
-
let sassGlob =
|
|
25
|
+
let sassGlob = globSync(sassGlobPath, {
|
|
26
26
|
ignore: [
|
|
27
27
|
project.path + '/_src/style/partials/_theme.scss'
|
|
28
28
|
]
|
|
29
29
|
});
|
|
30
30
|
let jsGlobPath = project.package?.sdc?.jsGlobPath || project.path + '/_src/scripts/**/*.js';
|
|
31
|
-
let jsGlob =
|
|
31
|
+
let jsGlob = globSync(jsGlobPath, {
|
|
32
32
|
ignore: []
|
|
33
33
|
});
|
|
34
34
|
let blockGlobPath = project.package?.sdc?.blockGlobPath || project.path + '/blocks/*';
|
|
35
|
-
let blockGlob =
|
|
35
|
+
let blockGlob = globSync(blockGlobPath);
|
|
36
36
|
|
|
37
37
|
function bustFunctionsCache() {
|
|
38
38
|
bustCache(project.path + '/functions.php');
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function frontrunImages() {
|
|
42
|
-
[
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
[
|
|
43
|
+
project.path + '/_src/images/',
|
|
44
|
+
project.path + '/_src/images/**/*/'
|
|
45
|
+
].forEach((block) => {
|
|
46
|
+
const imageDirectories = globSync(block);
|
|
47
|
+
imageDirectories.forEach((dir) => {
|
|
48
|
+
buildImages(dir);
|
|
47
49
|
});
|
|
48
50
|
});
|
|
49
51
|
}
|
|
@@ -55,7 +57,7 @@ for (const [name, files] of Object.entries(project.package.sdc.entries)) {
|
|
|
55
57
|
entries[name].push(project.path + file);
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
|
-
let sassBlocksGlob =
|
|
60
|
+
let sassBlocksGlob = globSync(project.path + '/blocks/*/*.scss');
|
|
59
61
|
for (var filename of sassBlocksGlob) {
|
|
60
62
|
entries[`blocks/${path.basename(path.dirname(filename))}/style`] = [ filename ];
|
|
61
63
|
}
|
package/lib/images.js
CHANGED
|
@@ -7,15 +7,16 @@ import imageminSvgo from 'imagemin-svgo';
|
|
|
7
7
|
|
|
8
8
|
const buildImages = async (images) => {
|
|
9
9
|
let timerStart = Date.now();
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
let dest = images.replace('_src/images', 'dist/images');
|
|
11
|
+
const files = await imagemin([images + '/*'], {
|
|
12
|
+
destination: dest,
|
|
12
13
|
plugins: [
|
|
13
14
|
imageminJpegtran(),
|
|
14
15
|
imageminPngquant(),
|
|
15
16
|
imageminSvgo()
|
|
16
17
|
]
|
|
17
18
|
});
|
|
18
|
-
log('success', `Built
|
|
19
|
+
log('success', `Built ${dest.replace(project.path, '')} (${files.length} image${files.length == 1 ? '' : 's'}) in ${Date.now() - timerStart}ms`);
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export default buildImages;
|