sdc-build-wp 1.3.3 → 2.0.2

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/.stylelintrc CHANGED
@@ -1,15 +1,23 @@
1
1
  {
2
- "rules": {
3
- "indentation": "tab",
4
- "max-empty-lines": 1,
5
- "rule-empty-line-before": [
6
- "always",
7
- {
8
- "ignore": [
9
- "after-comment"
10
- ]
11
- }
12
- ],
13
- "color-no-invalid-hex": true
14
- }
2
+ "rules": {
3
+ "indentation": "tab",
4
+ "max-empty-lines": 1,
5
+ "rule-empty-line-before": [
6
+ "always",
7
+ {
8
+ "ignore": [ "after-comment" ]
9
+ }
10
+ ],
11
+ "block-opening-brace-space-before": "always-multi-line",
12
+ "block-opening-brace-newline-after": "always-multi-line",
13
+ "no-empty-first-line": true,
14
+ "selector-max-empty-lines": 0,
15
+ "color-function-notation": "modern",
16
+ "color-hex-length": "long",
17
+ "color-no-invalid-hex": true,
18
+ "color-named": "never",
19
+ "shorthand-property-no-redundant-values": true,
20
+ "number-leading-zero": "always",
21
+ "no-eol-whitespace": true
22
+ }
15
23
  }
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) => {
@@ -8,7 +8,8 @@ const buildBrowserSync = () => {
8
8
  proxy: project.package.sdc?.browsersync?.localProxyURL,
9
9
  files: [
10
10
  project.path + '/dist/**/*',
11
- project.path + '/**/*.php'
11
+ project.path + '/**/*.php',
12
+ project.path + '/**/*.html'
12
13
  ],
13
14
  open: project.package.sdc?.open || false,
14
15
  https: (process.env.SSL_KEY_PATH && process.env.SSL_CRT_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 buildSass = (entry, entriesToLint) => {
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 write auto-generated _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, '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "1.3.3",
3
+ "version": "2.0.2",
4
4
  "description": "Custom WordPress build process.",
5
5
  "author": {
6
6
  "name": "Robert Sefer",
@@ -21,21 +21,21 @@
21
21
  "dependencies": {
22
22
  "autoprefixer": "^10.4.0",
23
23
  "browser-sync": "^2.27.7",
24
- "chalk": "^4.1.2",
24
+ "chalk": "^5.0.0",
25
25
  "chokidar": "^3.5.2",
26
- "esbuild": "^0.13.14",
27
- "eslint": "^8.2.0",
26
+ "esbuild": "^0.14.8",
27
+ "eslint": "^8.5.0",
28
28
  "fs-extra": "^10.0.0",
29
29
  "glob": "^7.2.0",
30
30
  "imagemin": "^8.0.1",
31
31
  "imagemin-jpegtran": "^7.0.0",
32
32
  "imagemin-pngquant": "^9.0.2",
33
- "imagemin-svgo": "^10.0.0",
33
+ "imagemin-svgo": "^10.0.1",
34
34
  "minimist": "^1.2.5",
35
- "postcss": "^8.3.11",
35
+ "postcss": "^8.4.5",
36
36
  "postcss-scss": "^4.0.2",
37
- "postcss-sort-media-queries": "^4.1.0",
38
- "sass": "^1.43.4",
39
- "stylelint": "^14.1.0"
37
+ "postcss-sort-media-queries": "^4.2.1",
38
+ "sass": "^1.45.1",
39
+ "stylelint": "^14.2.0"
40
40
  }
41
41
  }