@ideasonpurpose/build-tools-wordpress 2.4.2 → 2.5.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.
@@ -6,6 +6,7 @@ on:
6
6
 
7
7
  jobs:
8
8
  build:
9
+ # https://github.com/actions/runner-images
9
10
  name: Build Release
10
11
  # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
11
12
  runs-on: ubuntu-24.04
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### v2.5.0
8
+
9
+ > 7 March 2026
10
+
11
+ - bump deps
12
+ - beginning of typing, some cleanup
13
+ - inline SVGs in SCSS files by default
14
+
15
+ #### v2.4.2
16
+
17
+ > 22 December 2025
18
+
19
+ - Update npm publish command with options
20
+
7
21
  #### v2.4.1
8
22
 
9
23
  > 22 December 2025
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ideasonpurpose/build-tools-wordpress
2
2
 
3
- #### Version 2.4.2
3
+ #### Version 2.5.1
4
4
 
5
5
  [![NPM Version](https://img.shields.io/npm/v/%40ideasonpurpose%2Fbuild-tools-wordpress?logo=npm)](https://www.npmjs.com/package/@ideasonpurpose/build-tools-wordpress)
6
6
  [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ideasonpurpose/build-tools-wordpress/npm-publish.yml?logo=github&logoColor=white)](https://github.com/ideasonpurpose/build-tools-wordpress#readme)
@@ -29,6 +29,18 @@ Each project may optionally include an **ideasonpurpose.config.js** file in the
29
29
 
30
30
  -->
31
31
 
32
+ ## SVG Processing
33
+
34
+ Webpack handles SVG files differently based on import context:
35
+
36
+ - **In SCSS files**: SVGs referenced via `url('file.svg')` are inlined as data URIs if under 4KB, otherwise emitted as separate files in the output directory.
37
+
38
+ - **In JS/TSX files**:
39
+ - With `?url` query (e.g., `import svg from 'file.svg?url'`): Treated as assets, inlined as data URIs if under 4KB, else files.
40
+ - Without `?url`: Converted to React components using `@svgr/webpack` for direct JSX usage.
41
+
42
+ Data URIs are generated as `data:image/svg+xml,<url-encoded-content>` using more efficient URL-encoding, not base64.
43
+
32
44
  ## Local Development
33
45
 
34
46
  Because this project makes use of bin scripts, conventional `npm link` workflows won't work correctly. To work on this code in a development project, change the project's package.json to install from a local file path, probably something like this:
@@ -79,6 +79,9 @@ const stats = {
79
79
  loggingDebug: ["sass-loader"],
80
80
  };
81
81
 
82
+ /**
83
+ * @param {Record<string, any>} env - Environment variables from Webpack CLI
84
+ */
82
85
  export default async (env) => {
83
86
  // const siteDir = new URL(import.meta.url).pathname;
84
87
  const siteDir = process.cwd();
@@ -89,6 +92,15 @@ export default async (env) => {
89
92
 
90
93
  const proxy = isProduction ? {} : await devserverProxy(config);
91
94
 
95
+
96
+ /**
97
+ * Simple helper for encoding SVGs as data urls with proper encoding for special characters
98
+ * @param {Buffer} content
99
+ * @returns {string} - Encoded SVG data URL
100
+ */
101
+ const svgDataUrlHelper = (content) =>
102
+ `data:image/svg+xml,${encodeURIComponent(content.toString())}`;
103
+
92
104
  // console.log({config});
93
105
  // console.log({entry: config.entry});
94
106
  /**
@@ -101,11 +113,11 @@ export default async (env) => {
101
113
  *
102
114
  * TODO: Why so much dancing around defaults when this could just inherit from default.config?
103
115
  */
104
- const usePolling = Boolean(config.usePolling); // likely undefined, coerced to false
105
- const pollInterval = Math.max(
106
- parseInt(config.pollInterval, 10) || parseInt(config.usePolling, 10) || 400,
107
- 400,
108
- );
116
+ // const usePolling = Boolean(config.usePolling); // likely undefined, coerced to false
117
+ // const pollInterval = Math.max(
118
+ // parseInt(config.pollInterval, 10) || parseInt(config.usePolling, 10) || 400,
119
+ // 400,
120
+ // );
109
121
 
110
122
  const devtool = config.devtool || false;
111
123
 
@@ -200,17 +212,35 @@ export default async (env) => {
200
212
  /**
201
213
  * SVGs can be imported as asset urls or React components
202
214
  *
215
+ * In SCSS files, SVGs will be treated as assets and inlined as data urls
216
+ * unless they are larger than 4kb
217
+ *
203
218
  * To import an SVG file as a src url, append ?url to the filename:
204
219
  * import svg from './assets/file.svg?url'
205
220
  *
206
- * To import an SVG file as a React component
207
-
208
221
  * @link https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
209
222
  */
223
+ {
224
+ test: /\.svg$/i,
225
+ issuer: /\.scss$/,
226
+ type: "asset",
227
+ parser: {
228
+ dataUrlCondition: { maxSize: 4096 },
229
+ },
230
+ generator: {
231
+ dataUrl: svgDataUrlHelper,
232
+ },
233
+ },
210
234
  {
211
235
  test: /\.svg$/i,
212
236
  type: "asset",
213
237
  resourceQuery: /url/, // *.svg?url
238
+ parser: {
239
+ dataUrlCondition: { maxSize: 4096 },
240
+ },
241
+ generator: {
242
+ dataUrl: svgDataUrlHelper,
243
+ },
214
244
  },
215
245
  {
216
246
  test: /\.svg$/i,
@@ -359,6 +389,9 @@ export default async (env) => {
359
389
  // return true;
360
390
  // },
361
391
 
392
+ /**
393
+ * @param {Object} devServer - The devServer instance
394
+ */
362
395
  onListening: (devServer) => {
363
396
  const port = devServer.server.address().port;
364
397
  devServer.compiler.options.devServer.port =
@@ -368,6 +401,10 @@ export default async (env) => {
368
401
  console.log("Listening on port:", port);
369
402
  },
370
403
 
404
+ /**
405
+ * @param {Array<Function>} middlewares - Array of middleware functions
406
+ * @param {Object} devServer - The devServer instance
407
+ */
371
408
  setupMiddlewares: (middlewares, devServer) => {
372
409
  /**
373
410
  * The `/inform` route is an annoying bit of code. Here's why:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ideasonpurpose/build-tools-wordpress",
3
- "version": "2.4.2",
3
+ "version": "2.5.1",
4
4
  "description": "Build scripts and dependencies for IOP's WordPress development environments.",
5
5
  "homepage": "https://github.com/ideasonpurpose/build-tools-wordpress#readme",
6
6
  "bugs": {
@@ -36,69 +36,70 @@
36
36
  "@ideasonpurpose/prettier-config": "^1.0.1",
37
37
  "@ideasonpurpose/stylelint-config": "^1.1.4",
38
38
  "@prettier/plugin-php": "^0.24.0",
39
- "@rollup/plugin-commonjs": "^29.0.0",
39
+ "@rollup/plugin-commonjs": "^29.0.2",
40
40
  "@rollup/plugin-json": "^6.1.0",
41
41
  "@rollup/plugin-node-resolve": "^16.0.3",
42
42
  "@svgr/webpack": "^8.1.0",
43
- "@wordpress/dependency-extraction-webpack-plugin": "^6.36.0",
43
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.41.0",
44
44
  "ansi-html": "^0.0.9",
45
45
  "archiver": "^7.0.1",
46
46
  "auto-changelog": "^2.5.0",
47
- "autoprefixer": "^10.4.23",
48
- "babel-loader": "^10.0.0",
49
- "caniuse-lite": "^1.0.30001761",
47
+ "autoprefixer": "^10.4.27",
48
+ "babel-loader": "^10.1.0",
49
+ "caniuse-lite": "^1.0.30001777",
50
50
  "chalk": "^5.6.2",
51
51
  "chalk-cli": "^6.0.0",
52
52
  "classnames": "^2.5.1",
53
- "cli-truncate": "^5.1.1",
54
- "copy-webpack-plugin": "^13.0.1",
55
- "cosmiconfig": "^9.0.0",
53
+ "cli-truncate": "^5.2.0",
54
+ "copy-webpack-plugin": "^14.0.0",
55
+ "cosmiconfig": "^9.0.1",
56
56
  "cross-env": "^10.1.0",
57
- "css-loader": "^7.1.2",
58
- "cssnano": "^7.1.2",
59
- "dotenv": "^17.2.3",
60
- "esbuild-loader": "^4.4.1",
61
- "eslint": "^9.39.2",
57
+ "css-loader": "^7.1.4",
58
+ "cssnano": "^7.1.3",
59
+ "dotenv": "^17.3.1",
60
+ "esbuild-loader": "^4.4.2",
61
+ "eslint": "^10.0.3",
62
62
  "filesize": "^11.0.13",
63
- "fs-extra": "^11.3.3",
64
- "globby": "^16.0.0",
65
- "html-webpack-plugin": "^5.6.5",
63
+ "fs-extra": "^11.3.4",
64
+ "globby": "^16.1.1",
65
+ "html-webpack-plugin": "^5.6.6",
66
66
  "http-proxy": "^1.18.1",
67
67
  "humanize-duration": "^3.33.2",
68
- "image-minimizer-webpack-plugin": "^4.1.4",
68
+ "image-minimizer-webpack-plugin": "^5.0.0",
69
69
  "is-text-path": "^3.0.0",
70
- "lodash": "^4.17.21",
71
- "mini-css-extract-plugin": "^2.9.4",
72
- "ora": "^9.0.0",
73
- "postcss": "^8.5.6",
74
- "postcss-loader": "^8.2.0",
70
+ "lodash": "^4.17.23",
71
+ "mini-css-extract-plugin": "^2.10.0",
72
+ "ora": "^9.3.0",
73
+ "postcss": "^8.5.8",
74
+ "postcss-loader": "^8.2.1",
75
75
  "postcss-scss": "^4.0.9",
76
- "prettier": "^3.7.4",
76
+ "prettier": "^3.8.1",
77
77
  "pretty-hrtime": "^1.0.3",
78
78
  "read-package-up": "^12.0.0",
79
79
  "replacestream": "^4.0.3",
80
- "sass-embedded": "^1.97.1",
81
- "sass-loader": "^16.0.6",
82
- "semver": "^7.7.3",
80
+ "rimraf": "^6.1.3",
81
+ "sass-embedded": "^1.97.3",
82
+ "sass-loader": "^16.0.7",
83
+ "semver": "^7.7.4",
83
84
  "sharp": "^0.34.5",
84
- "sort-package-json": "^3.6.0",
85
- "string-length": "^6.0.0",
85
+ "sort-package-json": "^3.6.1",
86
+ "string-length": "^7.0.1",
86
87
  "style-loader": "^4.0.0",
87
- "svgo": "^4.0.0",
88
+ "svgo": "^4.0.1",
88
89
  "svgo-loader": "^4.0.0",
89
90
  "version-everything": "^0.11.4",
90
- "webpack": "^5.104.1",
91
- "webpack-bundle-analyzer": "^5.1.0",
91
+ "webpack": "^5.105.4",
92
+ "webpack-bundle-analyzer": "^5.2.0",
92
93
  "webpack-dev-middleware": "^7.4.5",
93
- "webpack-dev-server": "^5.2.2",
94
+ "webpack-dev-server": "^5.2.3",
94
95
  "webpack-manifest-plugin": "^6.0.1"
95
96
  },
96
97
  "peerDependencies": {
97
98
  "webpack-cli": "^6.0.1"
98
99
  },
99
100
  "devDependencies": {
100
- "@vitest/coverage-v8": "^4.0.16",
101
- "vitest": "^4.0.16"
101
+ "@vitest/coverage-v8": "^4.0.18",
102
+ "vitest": "^4.0.18"
102
103
  },
103
104
  "version-everything": {
104
105
  "files": [