sdc-build-wp 3.0.7 → 3.1.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.
@@ -13,6 +13,7 @@ const buildBrowserSync = () => {
13
13
  project.path + '/**/*.html',
14
14
  project.path + '/**/*.json',
15
15
  ],
16
+ watchEvents: project.package.sdc?.browsersync?.watchEvents || ['add', 'change', 'unlink', 'addDir', 'unlinkDir'],
16
17
  open: project.package.sdc?.open || false,
17
18
  https: (process.env.SSL_KEY_PATH && process.env.SSL_CRT_PATH ? {
18
19
  key: process.env.SSL_KEY_PATH,
package/lib/style.js CHANGED
@@ -13,7 +13,26 @@ import { promises } from 'fs';
13
13
  const buildColors = async () => {
14
14
  try {
15
15
  let theme = JSON.parse(await promises.readFile(project.path + '/theme.json'));
16
- let themeFileData = `// This file is automatically generated. Do not edit.\n`;
16
+ let themeFileData = `// This file is automatically generated from theme.json. Do not edit.\n`;
17
+ if (theme.settings.custom && theme.settings.custom['dirDist']) {
18
+ themeFileData += `$themeDirDist: "${theme.settings.custom['dirDist']}";\n`;
19
+ }
20
+ if (theme.styles?.typography) {
21
+ if (theme.styles.typography.fontSize) {
22
+ let fontSizeBase = theme.styles.typography.fontSize;
23
+ themeFileData += `$font-size-base: ${theme.styles.typography.fontSize}; // --wp--preset--font-size\n`;
24
+ if (theme.settings.custom && theme.settings.custom['breakpoints-rem']) {
25
+ for (var breakpoint in theme.settings.custom['breakpoints-rem']) {
26
+ themeFileData += `$screen-${breakpoint}: ${theme.settings.custom['breakpoints-rem'][breakpoint]}rem;\n`;
27
+ themeFileData += `$screen-${breakpoint}-px: ${theme.settings.custom['breakpoints-rem'][breakpoint] * fontSizeBase.replace('px', '')}px;\n`;
28
+ }
29
+ if (theme.settings.custom['breakpoint-mobile']) {
30
+ themeFileData += `$mobile-breakpoint: $screen-${theme.settings.custom['breakpoint-mobile']};\n`;
31
+ themeFileData += `$mobile-breakpoint-px: $screen-${theme.settings.custom['breakpoint-mobile']}-px;\n`;
32
+ }
33
+ }
34
+ }
35
+ }
17
36
  if (theme.settings?.typography?.fontFamilies) {
18
37
  for (var fontFamily of theme.settings.typography.fontFamilies) {
19
38
  themeFileData += `$${fontFamily['slug']}: ${fontFamily['fontFamily']}; // --wp--preset--font-family--${fontFamily['slug']}\n`;
@@ -31,10 +50,12 @@ const buildColors = async () => {
31
50
  }
32
51
  try {
33
52
  await promises.writeFile(project.path + '/_src/style/partials/_theme.scss', themeFileData);
34
- } catch {
53
+ } catch(error) {
54
+ console.error(error);
35
55
  log('error', `Failed to write auto-generated _theme.scss - See above error.`);
36
56
  }
37
- } catch {
57
+ } catch(error) {
58
+ console.error(error);
38
59
  log('error', `Failed to read theme.json - See above error.`);
39
60
  }
40
61
  };
@@ -55,7 +76,7 @@ const buildSass = async (entry, name, entriesToLint) => {
55
76
  fix: true
56
77
  }).then((data) => {
57
78
  if (data.errored) {
58
- console.log(data.output);
79
+ console.error(data.output);
59
80
  log('error', `Failed linting ${entry.replace(project.path + '/_src/style/', '')} - See above error.`);
60
81
  return false;
61
82
  }
@@ -65,9 +86,9 @@ const buildSass = async (entry, name, entriesToLint) => {
65
86
  });
66
87
  fs.writeFile(outFile, result.css, function(err) {
67
88
  if (err) {
68
- console.log(err);
69
- log('error', `Failed building ${entryLabel} - See above error.`);
70
- return false;
89
+ // console.error(err);
90
+ // log('error', `Failed compiling ${entryLabel} - See above error.`);
91
+ // return false;
71
92
  } else {
72
93
  if (!fs.existsSync(project.path + '/dist')) {
73
94
  fs.mkdirSync(project.path + '/dist');
@@ -91,9 +112,10 @@ const buildSass = async (entry, name, entriesToLint) => {
91
112
  });
92
113
  }
93
114
  });
94
- } catch {
115
+ } catch(error) {
116
+ console.error(error);
95
117
  log('error', `Failed building ${entryLabel} - See above error.`);
96
- return false;
118
+ return false;
97
119
  }
98
120
  });
99
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "3.0.7",
3
+ "version": "3.1.0",
4
4
  "description": "Custom WordPress build process.",
5
5
  "author": {
6
6
  "name": "Robert Sefer",