sdc-build-wp 3.0.0 → 3.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/lib/blocks.js +2 -2
- package/lib/style.js +35 -31
- package/package.json +2 -2
package/lib/blocks.js
CHANGED
|
@@ -10,7 +10,7 @@ function cmd(...command) {
|
|
|
10
10
|
shell: true
|
|
11
11
|
});
|
|
12
12
|
return new Promise((resolveFunc) => {
|
|
13
|
-
// p.stdout.on(
|
|
13
|
+
// p.stdout.on('data', (x) => {
|
|
14
14
|
// process.stdout.write(x.toString());
|
|
15
15
|
// });
|
|
16
16
|
p.stderr.on('data', (x) => {
|
|
@@ -43,7 +43,7 @@ const buildBlock = async (entry) => {
|
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
let timerStart = Date.now();
|
|
46
|
-
await cmd(`cd ${entry} && ${project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`, 'build');
|
|
46
|
+
await cmd(`cd ${entry} && ${project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`, 'build', 'src/index');
|
|
47
47
|
log('success', `Built ${entry.replace(project.path, '')} in ${Date.now() - timerStart}ms`);
|
|
48
48
|
};
|
|
49
49
|
|
package/lib/style.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import project from '../lib/project.js';
|
|
5
5
|
import log from './logging.js';
|
|
6
|
-
import sass from 'sass';
|
|
6
|
+
import * as sass from 'sass';
|
|
7
7
|
import postcss from 'postcss';
|
|
8
8
|
import autoprefixer from 'autoprefixer';
|
|
9
9
|
import sortMQ from 'postcss-sort-media-queries';
|
|
@@ -59,39 +59,43 @@ const buildSass = async (entry, name, entriesToLint) => {
|
|
|
59
59
|
log('error', `Failed linting ${entry.replace(project.path + '/_src/style/', '')} - See above error.`);
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
if (!fs.existsSync(project.path + '/dist/style')) {
|
|
76
|
-
fs.mkdirSync(project.path + '/dist/style');
|
|
77
|
-
}
|
|
78
|
-
postcss([
|
|
79
|
-
autoprefixer(),
|
|
80
|
-
sortMQ()
|
|
81
|
-
]).process(result.css, { from: undefined }).then(resultPost => {
|
|
82
|
-
fs.writeFile(outFile, resultPost.css, function(err) {
|
|
83
|
-
if (err) {
|
|
84
|
-
console.log(err);
|
|
85
|
-
log('error', `Failed saving ${entryLabel} - See above error.`);
|
|
86
|
-
return false;
|
|
87
|
-
} else {
|
|
88
|
-
log('success', `Built ${entryLabel} in ${Date.now() - timerStart}ms`);
|
|
62
|
+
try {
|
|
63
|
+
const result = sass.compile(entry, {
|
|
64
|
+
style: 'compressed'
|
|
65
|
+
});
|
|
66
|
+
fs.writeFile(outFile, result.css, function(err) {
|
|
67
|
+
if (err) {
|
|
68
|
+
console.log(err);
|
|
69
|
+
log('error', `Failed building ${entryLabel} - See above error.`);
|
|
70
|
+
return false;
|
|
71
|
+
} else {
|
|
72
|
+
if (!fs.existsSync(project.path + '/dist')) {
|
|
73
|
+
fs.mkdirSync(project.path + '/dist');
|
|
89
74
|
}
|
|
90
|
-
|
|
75
|
+
if (!fs.existsSync(project.path + '/dist/style')) {
|
|
76
|
+
fs.mkdirSync(project.path + '/dist/style');
|
|
77
|
+
}
|
|
78
|
+
postcss([
|
|
79
|
+
autoprefixer(),
|
|
80
|
+
sortMQ()
|
|
81
|
+
]).process(result.css, { from: undefined }).then(resultPost => {
|
|
82
|
+
fs.writeFile(outFile, resultPost.css, function(err) {
|
|
83
|
+
if (err) {
|
|
84
|
+
console.log(err);
|
|
85
|
+
log('error', `Failed saving ${entryLabel} - See above error.`);
|
|
86
|
+
return false;
|
|
87
|
+
} else {
|
|
88
|
+
log('success', `Built ${entryLabel} in ${Date.now() - timerStart}ms`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
91
93
|
});
|
|
92
|
-
}
|
|
94
|
+
} catch {
|
|
95
|
+
log('error', `Failed building ${entryLabel} - See above error.`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
93
98
|
});
|
|
94
|
-
|
|
95
99
|
};
|
|
96
100
|
|
|
97
101
|
export default buildSass;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdc-build-wp",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Custom WordPress build process.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Robert Sefer",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"postcss": "^8.4.20",
|
|
37
37
|
"postcss-scss": "^4.0.6",
|
|
38
38
|
"postcss-sort-media-queries": "^4.3.0",
|
|
39
|
-
"sass": "^1.
|
|
39
|
+
"sass": "^1.63.4",
|
|
40
40
|
"stylelint": "^14.16.0"
|
|
41
41
|
}
|
|
42
42
|
}
|