sdc-build-wp 2.5.0 → 2.6.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/README.md CHANGED
@@ -1 +1,11 @@
1
+ ## Install
2
+
3
+ ```sh
4
+ npm install sdc-build-wp
5
+ sdc-build-wp # build
6
+ sdc-build-wp --watch # build and watch
7
+ ```
8
+
9
+ ## Develop
10
+
1
11
  Develop locally with `node ~/sites/sdc/sdc-build-wp/index.js --watch` from within the test project directory.
package/index.js CHANGED
@@ -18,7 +18,7 @@ let chokidarOpts = {
18
18
  ignoreInitial: true
19
19
  };
20
20
 
21
- let sassGlobPath = project.package?.sdc?.sassGlobPath || project.path + '/_src/style/**/*.scss';
21
+ let sassGlobPath = project.package?.sdc?.sassGlobPath || project.path + '{/_src/style,/blocks}/**/*.scss';
22
22
  let sassGlob = glob.sync(sassGlobPath, {
23
23
  ignore: [
24
24
  project.path + '/_src/style/partials/_theme.scss'
@@ -48,6 +48,10 @@ for (const [name, files] of Object.entries(project.package.sdc.entries)) {
48
48
  entries[name].push(project.path + file);
49
49
  });
50
50
  }
51
+ let sassBlocksGlob = glob.sync(project.path + '/blocks/*/*.scss');
52
+ for (var filename of sassBlocksGlob) {
53
+ entries[`blocks/${path.basename(path.dirname(filename))}/style`] = [ filename ];
54
+ }
51
55
 
52
56
  let filesSass = [];
53
57
 
@@ -55,7 +59,10 @@ for (const [name, files] of Object.entries(entries)) {
55
59
  files.forEach(function(file) {
56
60
  switch (path.parse(file).ext) {
57
61
  case '.scss':
58
- filesSass.push(file);
62
+ filesSass.push({
63
+ 'name': name,
64
+ 'file': file
65
+ });
59
66
  break;
60
67
  case '.js':
61
68
  buildJS(file);
@@ -80,24 +87,22 @@ if (argv.watch) {
80
87
  });
81
88
  }
82
89
 
83
- filesSass.forEach((file) => {
84
- buildSass(file, sassGlob);
85
- bustFunctionsCache();
86
- });
90
+ function runSass() {
91
+ for (var block of filesSass) {
92
+ buildSass(block.file, block.name, sassGlob);
93
+ bustFunctionsCache();
94
+ }
95
+ }
96
+
97
+ runSass();
87
98
  if (argv.watch) {
88
99
  chokidar.watch(sassGlob, chokidarOpts).on('all', (event, path) => {
89
- filesSass.forEach((file) => {
90
- buildSass(file, sassGlob);
91
- bustFunctionsCache();
92
- });
100
+ runSass();
93
101
  });
94
102
  }
95
103
  if (argv.watch) {
96
104
  chokidar.watch(project.path + '/theme.json', chokidarOpts).on('all', (event, path) => {
97
- filesSass.forEach((file) => {
98
- buildSass(file, sassGlob);
99
- bustFunctionsCache();
100
- });
105
+ runSass();
101
106
  });
102
107
  }
103
108
 
@@ -4,12 +4,14 @@ const browserSync = bsCreate();
4
4
 
5
5
  const buildBrowserSync = () => {
6
6
  browserSync.init({
7
+ logPrefix: '',
7
8
  port: project.package.sdc?.port || 3000,
8
9
  proxy: project.package.sdc?.browsersync?.localProxyURL,
9
10
  files: [
10
11
  project.path + '/dist/**/*',
11
12
  project.path + '/**/*.php',
12
- project.path + '/**/*.html'
13
+ project.path + '/**/*.html',
14
+ project.path + '/**/*.json',
13
15
  ],
14
16
  open: project.package.sdc?.open || false,
15
17
  https: (process.env.SSL_KEY_PATH && process.env.SSL_CRT_PATH ? {
package/lib/style.js CHANGED
@@ -39,10 +39,13 @@ const buildColors = async () => {
39
39
  }
40
40
  };
41
41
 
42
- const buildSass = async (entry, entriesToLint) => {
42
+ const buildSass = async (entry, name, entriesToLint) => {
43
43
  await buildColors();
44
44
  let timerStart = Date.now();
45
- let outFile = project.path + '/dist/style/' + path.parse(entry).name + '.min.css';
45
+ let outFile = project.path + '/dist/' + name + '.min.css';
46
+ if (name.startsWith('blocks/')) {
47
+ outFile = project.path + '/' + name + '.min.css';
48
+ }
46
49
  let entryLabel = outFile.replace(project.path, '');
47
50
  stylelint.lint({
48
51
  configFile: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../.stylelintrc'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "Custom WordPress build process.",
5
5
  "author": {
6
6
  "name": "Robert Sefer",
@@ -19,23 +19,23 @@
19
19
  "sdc-build-wp": "./index.js"
20
20
  },
21
21
  "dependencies": {
22
- "autoprefixer": "^10.4.7",
23
- "browser-sync": "^2.27.10",
24
- "chalk": "^5.0.1",
22
+ "autoprefixer": "^10.4.13",
23
+ "browser-sync": "^2.27.11",
24
+ "chalk": "^5.2.0",
25
25
  "chokidar": "^3.5.3",
26
- "esbuild": "^0.14.46",
27
- "eslint": "^8.18.0",
28
- "fs-extra": "^10.1.0",
26
+ "esbuild": "^0.16.10",
27
+ "eslint": "^8.30.0",
28
+ "fs-extra": "^11.1.0",
29
29
  "glob": "^8.0.3",
30
30
  "imagemin": "^8.0.1",
31
31
  "imagemin-jpegtran": "^7.0.0",
32
32
  "imagemin-pngquant": "^9.0.2",
33
33
  "imagemin-svgo": "^10.0.1",
34
- "minimist": "^1.2.6",
35
- "postcss": "^8.4.5",
36
- "postcss-scss": "^4.0.4",
37
- "postcss-sort-media-queries": "^4.2.1",
38
- "sass": "^1.52.3",
39
- "stylelint": "^14.9.1"
34
+ "minimist": "^1.2.7",
35
+ "postcss": "^8.4.20",
36
+ "postcss-scss": "^4.0.6",
37
+ "postcss-sort-media-queries": "^4.3.0",
38
+ "sass": "^1.57.1",
39
+ "stylelint": "^14.16.0"
40
40
  }
41
41
  }