sdc-build-wp 4.3.5 → 4.4.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/eslint.config.js CHANGED
@@ -1,23 +1,25 @@
1
- export default [
1
+ import { defineConfig } from 'eslint/config';
2
+
3
+ export default defineConfig([
2
4
  {
3
5
  languageOptions: {
4
6
  parserOptions: {
5
- ecmaVersion: "latest",
6
- sourceType: "module",
7
+ ecmaVersion: 'latest',
8
+ sourceType: 'module',
7
9
  ecmaFeatures: {
8
- jsx: true,
9
- },
10
- },
10
+ jsx: true
11
+ }
12
+ }
11
13
  },
12
14
  rules: {
13
15
  semi: 1,
14
- indent: [1, "tab"],
15
- "no-multiple-empty-lines": [
16
+ indent: [1, 'tab'],
17
+ 'no-multiple-empty-lines': [
16
18
  1,
17
19
  {
18
- max: 1,
19
- },
20
- ],
21
- },
20
+ max: 1
21
+ }
22
+ ]
23
+ }
22
24
  }
23
- ];
25
+ ]);
@@ -7,14 +7,14 @@ export default class ScriptsComponent extends BaseComponent {
7
7
 
8
8
  constructor() {
9
9
  super();
10
- this.description = `Process javascript files`;
10
+ this.description = `Process script files`;
11
11
  }
12
12
 
13
13
  async init() {
14
- this.files = this.utils.addEntriesByFiletypes(['.js']);
14
+ this.files = this.utils.addEntriesByFiletypes(['.js', '.jsx', '.ts', '.tsx']);
15
15
  this.globs = await Array.fromAsync(
16
- this.glob(this.project.package?.sdc?.jsGlobPath ||
17
- `${this.project.path}/${this.project.paths.src.src}/${this.project.paths.src.scripts}/**/*.js`)
16
+ this.glob(this.project.package?.sdc?.scriptsGlobPath ||
17
+ `${this.project.path}/${this.project.paths.src.src}/${this.project.paths.src.scripts}/**/*.{js,jsx,ts,tsx}`)
18
18
  );
19
19
  await this.process();
20
20
  }
@@ -23,7 +23,7 @@ export default class ScriptsComponent extends BaseComponent {
23
23
  options = Object.assign({}, {
24
24
  entriesToLint: null
25
25
  }, options);
26
- let entryLabel = `/${this.project.paths.dist}/${this.project.paths.src.scripts}/${this.utils.entryBasename(entry).replace('.js', '.min.js')}`;
26
+ let entryLabel = `/${this.project.paths.dist}/${this.project.paths.src.scripts}/${this.utils.entryBasename(entry).replace(/\.js$|\.jsx$|\.ts$|\.tsx$/g, '.min.js')}`;
27
27
 
28
28
  this.start();
29
29
 
@@ -49,12 +49,11 @@ export default class ScriptsComponent extends BaseComponent {
49
49
  platform: 'node',
50
50
  entryPoints: [entry],
51
51
  bundle: true,
52
- loader: { '.js': 'jsx' },
53
52
  minify: true,
54
53
  outdir: `${this.project.paths.dist}/${this.project.paths.src.scripts}/`,
55
54
  entryNames: '[dir]/[name].min',
56
55
  plugins: [],
57
- sourcemap: true
56
+ sourcemap: process.env.NODE_ENV == 'production' ? false : true
58
57
  });
59
58
  if (result.warnings.length > 0) {
60
59
  log('warn', result.warnings);
@@ -71,8 +70,8 @@ export default class ScriptsComponent extends BaseComponent {
71
70
  }
72
71
 
73
72
  async process() {
74
- const promisesJS = this.files.map(block => this.build(block.file, { entriesToLint: this.globs }));
75
- await Promise.all(promisesJS);
73
+ const promisesScripts = this.files.map((block, index) => this.build(block.file, { entriesToLint: index == 0 ? this.globs : null }));
74
+ await Promise.all(promisesScripts);
76
75
  }
77
76
 
78
77
  watch() {
@@ -11,7 +11,7 @@ export default class StyleComponent extends BaseComponent {
11
11
 
12
12
  constructor() {
13
13
  super();
14
- this.description = `Process sass files`;
14
+ this.description = `Process style files`;
15
15
  }
16
16
 
17
17
  async init() {
@@ -116,13 +116,23 @@ export default class StyleComponent extends BaseComponent {
116
116
  throw Error('Linting error');
117
117
  }
118
118
  const compileResult = await sass.compileAsync(entry, {
119
- style: 'compressed'
119
+ style: 'compressed',
120
+ sourceMap: true
120
121
  });
121
122
  const postcssResult = await postcss([
122
123
  autoprefixer(),
123
124
  sortMQ()
124
- ]).process(compileResult.css, { from: undefined });
125
+ ]).process(compileResult.css, {
126
+ from: undefined,
127
+ to: outFile,
128
+ map: {
129
+ inline: false
130
+ }
131
+ });
125
132
  await fs.writeFile(outFile, postcssResult.css);
133
+ if (process.env.NODE_ENV != 'production') {
134
+ await fs.writeFile(`${outFile}.map`, postcssResult.map.toString());
135
+ }
126
136
  thisClass.end({
127
137
  itemLabel: entryLabel
128
138
  });
@@ -140,15 +150,17 @@ export default class StyleComponent extends BaseComponent {
140
150
  if (options.buildTheme) {
141
151
  await this.buildTheme();
142
152
  }
153
+ let i = 0;
143
154
  for (var block of this.files) {
144
155
  if (!entry || entry == block.file) {
145
156
  await this.build(block.file, {
146
157
  name: block.name,
147
- entriesToLint: this.globs
158
+ entriesToLint: i == 0 ? this.globs : null
148
159
  });
149
160
  if (entry == block.file) {
150
161
  break;
151
162
  }
163
+ i++;
152
164
  }
153
165
  }
154
166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "4.3.5",
3
+ "version": "4.4.1",
4
4
  "description": "Custom WordPress build process.",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -23,24 +23,27 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@stylistic/stylelint-plugin": "^3.1.2",
26
- "@wordpress/scripts": "^30.12.0",
27
- "autoprefixer": "^10.4.20",
26
+ "@typescript-eslint/eslint-plugin": "^8.26.1",
27
+ "@typescript-eslint/parser": "^8.26.1",
28
+ "@wordpress/scripts": "^30.13.0",
29
+ "autoprefixer": "^10.4.21",
28
30
  "browser-sync": "^3.0.3",
29
31
  "chalk": "^5.4.1",
30
32
  "chokidar": "^4.0.3",
31
- "esbuild": "^0.25.0",
32
- "eslint": "^9.21.0",
33
+ "esbuild": "^0.25.1",
34
+ "eslint": "^9.22.0",
33
35
  "fs-extra": "^11.3.0",
34
- "imagemin": "^9.0.0",
36
+ "imagemin": "^9.0.1",
35
37
  "imagemin-jpegtran": "^8.0.0",
36
38
  "imagemin-pngquant": "^10.0.0",
37
39
  "imagemin-svgo": "^11.0.1",
40
+ "jiti": "^2.4.2",
38
41
  "minimist": "^1.2.8",
39
42
  "postcss": "^8.5.3",
40
43
  "postcss-scss": "^4.0.9",
41
44
  "postcss-sort-media-queries": "^5.2.0",
42
45
  "sass": "^1.85.1",
43
- "stylelint": "^16.15.0",
46
+ "stylelint": "^16.16.0",
44
47
  "tail": "^2.2.6"
45
48
  }
46
49
  }