chisel-scripts 2.1.0 → 2.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## <small>2.1.2 (2025-12-16)</small>
6
+
7
+ - make icons module optional ([94e4c6c](https://github.com/xfiveco/generator-chisel/commit/94e4c6c))
8
+
9
+ ## <small>2.1.1 (2025-12-16)</small>
10
+
11
+ - add wp interactivity api support, optimize css build, refactor webpack config ([319d822](https://github.com/xfiveco/generator-chisel/commit/319d822))
12
+
5
13
  ## 2.1.0 (2025-12-15)
6
14
 
7
15
  - add wp exp-modules support, update wp scripts, build file size limits, auto clear patterns cache, no ([728f566](https://github.com/xfiveco/generator-chisel/commit/728f566))
package/index.js CHANGED
@@ -59,46 +59,27 @@ function adjustWebpackConfig(baseConfig, directory) {
59
59
  })());
60
60
  })();
61
61
 
62
- const performance = {
63
- maxAssetSize: 512 * 1024,
64
- maxEntrypointSize: 512 * 1024,
65
- hints: isProduction ? 'warning' : false,
66
- };
67
-
68
- const isMultiConfig = Array.isArray(baseConfig);
69
-
70
- const updatedConfig = isMultiConfig
71
- ? baseConfig.map((config, index) => {
72
- let configEntry = {};
73
-
74
- // Config 0: standard build - JS + styles
75
- if (index === 0) {
76
- configEntry = {
77
- ...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
78
- ...entriesFromFiles(scriptsFiles),
79
- ...entriesFromFiles(stylesFiles),
80
- };
81
- }
82
- // Config 1: ESM build - For block only
83
- else if (index === 1) {
84
- configEntry = {
85
- ...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
86
- };
87
- }
88
-
89
- return {
90
- ...config,
91
- entry: configEntry,
92
- resolve: {
62
+ const preparedConfig = (config, index = null) => {
63
+ return {
64
+ ...config,
65
+ output: {
66
+ ...config.output,
67
+ clean: isProduction,
68
+ },
69
+ resolve: {
93
70
  ...(config.resolve || {}),
94
71
  alias: {
95
- ...((config.resolve && config.resolve.alias) || {}),
96
- '~design$': pathMod.join(src, 'design'),
97
- },
72
+ ...((config.resolve && config.resolve.alias) || {}),
73
+ '~design$': pathMod.join(src, 'design'),
98
74
  },
99
- performance: performance,
100
- devServer: config.devServer && {
101
- ...config.devServer,
75
+ },
76
+ performance: {
77
+ maxAssetSize: 512 * 1024,
78
+ maxEntrypointSize: 512 * 1024,
79
+ hints: isProduction ? 'warning' : false,
80
+ },
81
+ devServer: config.devServer && {
82
+ ...config.devServer,
102
83
  allowedHosts: [new URL(getUrl()).host],
103
84
  ...(process.env.CHISEL_PORT && {
104
85
  host: '0.0.0.0',
@@ -115,6 +96,15 @@ function adjustWebpackConfig(baseConfig, directory) {
115
96
  .replace(process.env.CHISEL_PORT, Number(process.env.CHISEL_PORT) + 1),
116
97
  },
117
98
  }),
99
+ setupMiddlewares: (middlewares, devServer) => {
100
+ if (!devServer) {
101
+ return middlewares;
102
+ }
103
+
104
+ console.log(`🌐 Dev server ready at: ${getUrl()}`);
105
+
106
+ return middlewares;
107
+ }
118
108
  },
119
109
  optimization: {
120
110
  ...config.optimization,
@@ -132,55 +122,49 @@ function adjustWebpackConfig(baseConfig, directory) {
132
122
  ],
133
123
  }),
134
124
  ],
135
- };
136
- })
137
- : {
138
- ...baseConfig,
139
- entry,
140
- resolve: {
141
- ...(baseConfig.resolve || {}),
142
- alias: {
143
- ...((baseConfig.resolve && baseConfig.resolve.alias) || {}),
144
- '~design$': pathMod.join(src, 'design'),
145
- },
146
- },
147
- performance: performance,
148
- devServer: baseConfig.devServer && {
149
- ...baseConfig.devServer,
150
- allowedHosts: [new URL(getUrl()).host],
151
- ...(process.env.CHISEL_PORT && {
152
- host: '0.0.0.0',
153
- port: Number(process.env.CHISEL_PORT) + 1,
154
- client: {
155
- ...baseConfig.devServer.client,
156
- overlay: {
157
- errors: true,
158
- warnings: false,
159
- runtimeErrors: false,
160
- },
161
- webSocketURL: new URL(getUrl())
162
- .toString()
163
- .replace(process.env.CHISEL_PORT, Number(process.env.CHISEL_PORT) + 1),
164
- },
165
- }),
166
- },
167
- optimization: {
168
- ...baseConfig.optimization,
169
- ...(!isProduction && { runtimeChunk: 'single' }),
170
- },
171
- plugins: [
172
- ...baseConfig.plugins,
173
- new CopyWebpackPlugin({
174
- patterns: [
125
+ module: {
126
+ ...(config.module || {}),
127
+ rules: [
128
+ ...(config.module?.rules || []),
175
129
  {
176
- from: '**/*.twig',
177
- context: 'src',
178
- noErrorOnMissing: true,
130
+ test: /\.(png|jpe?g|gif|svg)$/i,
131
+ type: 'asset/resource', // Load as file, not base64 in css - for smaller css file size.
179
132
  },
180
133
  ],
181
- }),
182
- ],
183
- };
134
+ },
135
+ }
136
+ }
137
+
138
+ const isMultiConfig = Array.isArray(baseConfig);
139
+
140
+ const updatedConfig = isMultiConfig
141
+ ? baseConfig.map((config, index) => {
142
+ let configEntry = {};
143
+
144
+ // Config 0: standard build - JS + styles
145
+ if (index === 0) {
146
+ configEntry = {
147
+ ...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
148
+ ...entriesFromFiles(scriptsFiles),
149
+ ...entriesFromFiles(stylesFiles),
150
+ };
151
+ }
152
+ // Config 1: ESM build - For blocks only
153
+ else if (index === 1) {
154
+ configEntry = {
155
+ ...(blockMetadataFiles.length > 0 && typeof config.entry === 'function' ? config.entry() : config.entry || {}),
156
+ };
157
+ }
158
+
159
+ return {
160
+ ...preparedConfig(config, index),
161
+ entry: configEntry,
162
+ }
163
+ })
164
+ : {
165
+ ...preparedConfig(baseConfig),
166
+ entry,
167
+ }
184
168
 
185
169
  return updatedConfig;
186
170
  }
@@ -13,7 +13,10 @@ function loadExtensions() {
13
13
  .sort();
14
14
 
15
15
  return Promise.all(
16
- files.map((file) => import(pathToFileURL(join(extensionsDir, file)))),
16
+ files.map(async (file) => {
17
+ const module = await import(pathToFileURL(join(extensionsDir, file)));
18
+ return { name: file, module };
19
+ })
17
20
  );
18
21
  }
19
22
 
@@ -24,14 +27,19 @@ export default function wpScripts(api) {
24
27
  .option(
25
28
  '--experimental-modules',
26
29
  'do not enable experimental modules',
30
+ )
31
+ .option(
32
+ '--use-icons-module',
33
+ 'Use icons generator (sprite) module'
27
34
  ),
28
35
  async (options) => {
29
36
  process.env.NODE_ENV = 'production';
30
37
 
31
38
  for (const extension of await loadExtensions()) {
32
- if (!extension.build) continue;
39
+ if (!extension.module.build || (extension.name === 'icons.mjs' && !options.useIconsModule)) continue;
40
+
33
41
 
34
- await extension.build(api);
42
+ await extension.module.build(api);
35
43
  }
36
44
 
37
45
  const args = ['wp-scripts', 'build'];
@@ -52,6 +60,10 @@ export default function wpScripts(api) {
52
60
  .option(
53
61
  '--experimental-modules',
54
62
  'do not enable experimental modules',
63
+ )
64
+ .option(
65
+ '--use-icons-module',
66
+ 'Use icons generator (sprite) module'
55
67
  ),
56
68
  async (options) => {
57
69
  process.env.NODE_ENV = 'development';
@@ -59,15 +71,15 @@ export default function wpScripts(api) {
59
71
  const extensions = await loadExtensions();
60
72
 
61
73
  for (const extension of extensions) {
62
- if (!extension.build) continue;
74
+ if (!extension.module.build || (extension.name === 'icons.mjs' && !options.useIconsModule)) continue;
63
75
 
64
- await extension.build(api);
76
+ await extension.module.build(api);
65
77
  }
66
78
 
67
79
  for (const extension of extensions) {
68
- if (!extension.start) continue;
80
+ if (!extension.module.module.build || (extension.name === 'icons.mjs' && !options.useIconsModule)) continue;
69
81
 
70
- await extension.start(api);
82
+ await extension.module.start(api);
71
83
  }
72
84
 
73
85
  const args = ['wp-scripts', 'start', '--hot'];
@@ -57,5 +57,8 @@ define( 'WP_DEBUG_DISPLAY', false );
57
57
  define( 'SCRIPT_DEBUG', true );
58
58
  define( 'WP_ENVIRONMENT_TYPE', 'development' );
59
59
 
60
+ // Icons module. Also requires packacke.json and scss configuration.
61
+ define( 'CHISEL_USE_ICONS_MODULE', false );
62
+
60
63
  /** The Database Collate type. Don't change this if in doubt. */
61
64
  define( 'DB_COLLATE', '' );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chisel-scripts",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Chisel scripts",
5
5
  "bin": {
6
6
  "chisel-scripts": "bin/chisel-scripts.js"
@@ -39,5 +39,5 @@
39
39
  "peerDependencies": {
40
40
  "@wordpress/scripts": "^27.9.0 || ^31.0.0 || ^31.1.0"
41
41
  },
42
- "gitHead": "f5cb01894754a85b6842fa10412986bb745ea43a"
42
+ "gitHead": "54768b8dd93e3773c3659f28445c9c6d76a2819c"
43
43
  }