sdc-build-wp 3.1.0 → 3.2.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/.stylelintrc.json +26 -0
- package/index.js +3 -2
- package/lib/scripts.js +1 -1
- package/lib/style.js +25 -11
- package/package.json +17 -16
- package/.stylelintrc +0 -23
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
"@stylistic/stylelint-plugin"
|
|
4
|
+
],
|
|
5
|
+
"rules": {
|
|
6
|
+
"@stylistic/indentation": "tab",
|
|
7
|
+
"@stylistic/max-empty-lines": 1,
|
|
8
|
+
"rule-empty-line-before": [
|
|
9
|
+
"always",
|
|
10
|
+
{
|
|
11
|
+
"ignore": [ "after-comment" ]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"@stylistic/block-opening-brace-space-before": "always-multi-line",
|
|
15
|
+
"@stylistic/block-opening-brace-newline-after": "always-multi-line",
|
|
16
|
+
"@stylistic/no-empty-first-line": true,
|
|
17
|
+
"@stylistic/selector-max-empty-lines": 0,
|
|
18
|
+
"color-function-notation": "modern",
|
|
19
|
+
"color-hex-length": "long",
|
|
20
|
+
"color-no-invalid-hex": true,
|
|
21
|
+
"color-named": "never",
|
|
22
|
+
"shorthand-property-no-redundant-values": true,
|
|
23
|
+
"@stylistic/number-leading-zero": "always",
|
|
24
|
+
"@stylistic/no-eol-whitespace": true
|
|
25
|
+
}
|
|
26
|
+
}
|
package/index.js
CHANGED
|
@@ -4,10 +4,10 @@ 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 } from 'glob';
|
|
8
8
|
|
|
9
9
|
import bustCache from './lib/bustCache.js';
|
|
10
|
-
import buildSass from './lib/style.js';
|
|
10
|
+
import { buildSass, buildSassTheme } from './lib/style.js';
|
|
11
11
|
import buildJS from './lib/scripts.js';
|
|
12
12
|
import buildBlock from './lib/blocks.js';
|
|
13
13
|
import buildImages from './lib/images.js';
|
|
@@ -97,6 +97,7 @@ if (argv.watch) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function runSass() {
|
|
100
|
+
buildSassTheme();
|
|
100
101
|
for (var block of filesSass) {
|
|
101
102
|
buildSass(block.file, block.name, sassGlob);
|
|
102
103
|
bustFunctionsCache();
|
package/lib/scripts.js
CHANGED
package/lib/style.js
CHANGED
|
@@ -10,12 +10,25 @@ import sortMQ from 'postcss-sort-media-queries';
|
|
|
10
10
|
import stylelint from 'stylelint';
|
|
11
11
|
import { promises } from 'fs';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
function camelToDash(camel) {
|
|
14
|
+
return camel.replace(/[A-Z]/g, m => '-' + m.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const buildSassTheme = async () => {
|
|
14
18
|
try {
|
|
15
19
|
let theme = JSON.parse(await promises.readFile(project.path + '/theme.json'));
|
|
16
20
|
let themeFileData = `// This file is automatically generated from theme.json. Do not edit.\n`;
|
|
17
|
-
if (theme.settings
|
|
18
|
-
|
|
21
|
+
if (theme.settings?.custom) {
|
|
22
|
+
for (var customAttribute in theme.settings.custom) {
|
|
23
|
+
if (customAttribute == 'dirDist') {
|
|
24
|
+
themeFileData += `$themeDirDist: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${camelToDash(customAttribute)}\n`;
|
|
25
|
+
} else if (['breakpoints-rem', 'breakpoint-mobile'].includes(customAttribute)) {
|
|
26
|
+
// handled later in file - see 'fontSizeBase'
|
|
27
|
+
} else {
|
|
28
|
+
themeFileData += `$${customAttribute}: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${camelToDash(customAttribute)}\n`;
|
|
29
|
+
//
|
|
30
|
+
}
|
|
31
|
+
}
|
|
19
32
|
}
|
|
20
33
|
if (theme.styles?.typography) {
|
|
21
34
|
if (theme.styles.typography.fontSize) {
|
|
@@ -23,11 +36,15 @@ const buildColors = async () => {
|
|
|
23
36
|
themeFileData += `$font-size-base: ${theme.styles.typography.fontSize}; // --wp--preset--font-size\n`;
|
|
24
37
|
if (theme.settings.custom && theme.settings.custom['breakpoints-rem']) {
|
|
25
38
|
for (var breakpoint in theme.settings.custom['breakpoints-rem']) {
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
if (theme.settings.custom['breakpoints-rem'][breakpoint].includes('rem')) {
|
|
40
|
+
themeFileData += `$screen-${breakpoint}: ${theme.settings.custom['breakpoints-rem'][breakpoint]}; // --wp--custom--breakpoints-rem--${breakpoint}\n`;
|
|
41
|
+
} else {
|
|
42
|
+
themeFileData += `$screen-${breakpoint}: ${theme.settings.custom['breakpoints-rem'][breakpoint]}rem; // --wp--custom--breakpoints-rem--${breakpoint} (without 'rem')\n`;
|
|
43
|
+
}
|
|
44
|
+
themeFileData += `$screen-${breakpoint}-px: ${theme.settings.custom['breakpoints-rem'][breakpoint].replace('rem', '') * fontSizeBase.replace('px', '')}px;\n`;
|
|
28
45
|
}
|
|
29
46
|
if (theme.settings.custom['breakpoint-mobile']) {
|
|
30
|
-
themeFileData += `$mobile-breakpoint: $screen-${theme.settings.custom['breakpoint-mobile']}
|
|
47
|
+
themeFileData += `$mobile-breakpoint: $screen-${theme.settings.custom['breakpoint-mobile']}; // --wp--custom--breakpoint-mobile \n`;
|
|
31
48
|
themeFileData += `$mobile-breakpoint-px: $screen-${theme.settings.custom['breakpoint-mobile']}-px;\n`;
|
|
32
49
|
}
|
|
33
50
|
}
|
|
@@ -60,8 +77,7 @@ const buildColors = async () => {
|
|
|
60
77
|
}
|
|
61
78
|
};
|
|
62
79
|
|
|
63
|
-
const buildSass = async (entry, name, entriesToLint) => {
|
|
64
|
-
await buildColors();
|
|
80
|
+
export const buildSass = async (entry, name, entriesToLint) => {
|
|
65
81
|
let timerStart = Date.now();
|
|
66
82
|
let outFile = project.path + '/dist/' + name + '.min.css';
|
|
67
83
|
if (name.startsWith('blocks/')) {
|
|
@@ -69,7 +85,7 @@ const buildSass = async (entry, name, entriesToLint) => {
|
|
|
69
85
|
}
|
|
70
86
|
let entryLabel = outFile.replace(project.path, '');
|
|
71
87
|
stylelint.lint({
|
|
72
|
-
configFile: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../.stylelintrc'),
|
|
88
|
+
configFile: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../.stylelintrc.json'),
|
|
73
89
|
formatter: 'string',
|
|
74
90
|
files: entriesToLint || [entry],
|
|
75
91
|
customSyntax: 'postcss-scss',
|
|
@@ -119,5 +135,3 @@ const buildSass = async (entry, name, entriesToLint) => {
|
|
|
119
135
|
}
|
|
120
136
|
});
|
|
121
137
|
};
|
|
122
|
-
|
|
123
|
-
export default buildSass;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdc-build-wp",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Custom WordPress build process.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Robert Sefer",
|
|
@@ -19,24 +19,25 @@
|
|
|
19
19
|
"sdc-build-wp": "./index.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
22
|
+
"@stylistic/stylelint-plugin": "^2.1.1",
|
|
23
|
+
"@wordpress/scripts": "^27.5.0",
|
|
24
|
+
"autoprefixer": "^10.4.19",
|
|
25
|
+
"browser-sync": "^3.0.2",
|
|
26
|
+
"chalk": "^5.3.0",
|
|
27
|
+
"chokidar": "^3.6.0",
|
|
28
|
+
"esbuild": "^0.20.2",
|
|
29
|
+
"eslint": "^8.57.0",
|
|
30
|
+
"fs-extra": "^11.2.0",
|
|
31
|
+
"glob": "^10.3.12",
|
|
31
32
|
"imagemin": "^8.0.1",
|
|
32
33
|
"imagemin-jpegtran": "^7.0.0",
|
|
33
34
|
"imagemin-pngquant": "^9.0.2",
|
|
34
35
|
"imagemin-svgo": "^10.0.1",
|
|
35
|
-
"minimist": "^1.2.
|
|
36
|
-
"postcss": "^8.4.
|
|
37
|
-
"postcss-scss": "^4.0.
|
|
38
|
-
"postcss-sort-media-queries": "^
|
|
39
|
-
"sass": "^1.
|
|
40
|
-
"stylelint": "^
|
|
36
|
+
"minimist": "^1.2.8",
|
|
37
|
+
"postcss": "^8.4.38",
|
|
38
|
+
"postcss-scss": "^4.0.9",
|
|
39
|
+
"postcss-sort-media-queries": "^5.2.0",
|
|
40
|
+
"sass": "^1.72.0",
|
|
41
|
+
"stylelint": "^16.3.1"
|
|
41
42
|
}
|
|
42
43
|
}
|
package/.stylelintrc
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
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
|
-
}
|
|
23
|
-
}
|