@caweb/webpack 1.5.8 → 1.5.10
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/package.json +4 -1
- package/webpack.config.js +48 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/webpack",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.10",
|
|
4
4
|
"description": "CAWebPublishing Webpack Configuration",
|
|
5
5
|
"main": "webpack.config.js",
|
|
6
6
|
"files": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/CAWebPublishing/webpack#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
40
41
|
"@wordpress/scripts": "^30.20.0",
|
|
41
42
|
"css-minimizer-webpack-plugin": "^7.0.2",
|
|
42
43
|
"handlebars-loader": "^1.7.3",
|
|
@@ -45,6 +46,8 @@
|
|
|
45
46
|
"html-webpack-skip-assets-plugin": "^1.0.4",
|
|
46
47
|
"mini-css-extract-plugin": "^2.9.2",
|
|
47
48
|
"rtlcss-webpack-plugin": "^4.0.7",
|
|
49
|
+
"thread-loader": "^4.0.2",
|
|
50
|
+
"ts-loader": "^9.5.4",
|
|
48
51
|
"webpack": "^5.102.1",
|
|
49
52
|
"webpack-dev-server": "^5.2.2",
|
|
50
53
|
"webpack-remove-empty-scripts": "^1.1.1"
|
package/webpack.config.js
CHANGED
|
@@ -107,11 +107,30 @@ baseConfig.module.rules.forEach((rule, i) => {
|
|
|
107
107
|
delete rule.issuer;
|
|
108
108
|
}
|
|
109
109
|
break;
|
|
110
|
+
// silence deprecation warnings from sass
|
|
110
111
|
case new RegExp(/\.(sc|sa)ss$/).toString():
|
|
111
112
|
rule.use[rule.use.length-1].options.sassOptions = {
|
|
112
113
|
silenceDeprecations: ['global-builtin', 'import', 'color-functions']
|
|
113
114
|
};
|
|
114
115
|
break;
|
|
116
|
+
case new RegExp(/\.m?(j|t)sx?$/).toString():
|
|
117
|
+
// @since @wordpress/scripts@30.20.0 babel-loader is used for js and ts files
|
|
118
|
+
|
|
119
|
+
// Added the Transform class properties syntax plugin to the babel-loader.
|
|
120
|
+
// @see https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
|
|
121
|
+
rule.use[0].options.plugins.push('@babel/plugin-proposal-class-properties');
|
|
122
|
+
|
|
123
|
+
// we add thread-loader before the babel-loader
|
|
124
|
+
// Spawns multiple processes and split work between them. This makes faster build.
|
|
125
|
+
// @see https://webpack.js.org/loaders/thread-loader/
|
|
126
|
+
rule.use = [{
|
|
127
|
+
loader: 'thread-loader',
|
|
128
|
+
options: {
|
|
129
|
+
workers: -1,
|
|
130
|
+
},
|
|
131
|
+
}].concat(rule.use);
|
|
132
|
+
|
|
133
|
+
break;
|
|
115
134
|
}
|
|
116
135
|
});
|
|
117
136
|
|
|
@@ -276,8 +295,16 @@ let webpackConfig = {
|
|
|
276
295
|
// Handle `.tsx` and `.ts` files.
|
|
277
296
|
{
|
|
278
297
|
test: /\.tsx?$/,
|
|
279
|
-
use: 'ts-loader',
|
|
280
298
|
exclude: /node_modules/,
|
|
299
|
+
use: [
|
|
300
|
+
{
|
|
301
|
+
loader: 'ts-loader',
|
|
302
|
+
options: {
|
|
303
|
+
happyPackMode: true,
|
|
304
|
+
transpileOnly: true,
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
],
|
|
281
308
|
}
|
|
282
309
|
]
|
|
283
310
|
},
|
|
@@ -289,11 +316,11 @@ let webpackConfig = {
|
|
|
289
316
|
// @see https://webpack.js.org/configuration/externals/#externals
|
|
290
317
|
externals: {
|
|
291
318
|
// Third party dependencies.
|
|
292
|
-
jquery: 'jQuery',
|
|
293
319
|
underscore: '_',
|
|
320
|
+
jquery: 'jQuery',
|
|
294
321
|
lodash: 'lodash',
|
|
295
|
-
react:
|
|
296
|
-
'react-dom':
|
|
322
|
+
react: 'React',
|
|
323
|
+
'react-dom': 'ReactDOM',
|
|
297
324
|
|
|
298
325
|
// WordPress dependencies.
|
|
299
326
|
'@wordpress/hooks': ['vendor', 'wp', 'hooks'],
|
|
@@ -334,6 +361,15 @@ if( 'serve' === webpackCommand ){
|
|
|
334
361
|
*/
|
|
335
362
|
{
|
|
336
363
|
directory: path.join(appPath, 'node_modules'),
|
|
364
|
+
},
|
|
365
|
+
/**
|
|
366
|
+
* Static files are served from the following files in the following order
|
|
367
|
+
* we don't have to add the build directory since that is the output.path and proxied
|
|
368
|
+
*
|
|
369
|
+
* node_modules - Allows loading files from other npm packages
|
|
370
|
+
*/
|
|
371
|
+
{
|
|
372
|
+
directory: path.join(appPath, 'media'),
|
|
337
373
|
}
|
|
338
374
|
],
|
|
339
375
|
proxy:[
|
|
@@ -356,6 +392,14 @@ if( 'serve' === webpackCommand ){
|
|
|
356
392
|
context: ['/node_modules'],
|
|
357
393
|
target: `${server}://${host}:${port}`,
|
|
358
394
|
pathRewrite: { '^/node_modules': '' },
|
|
395
|
+
},
|
|
396
|
+
/**
|
|
397
|
+
* We proxy the node_modules and src so they serve from the root
|
|
398
|
+
*/
|
|
399
|
+
{
|
|
400
|
+
context: ['/media'],
|
|
401
|
+
target: `${server}://${host}:${port}`,
|
|
402
|
+
pathRewrite: { '^/media': '' },
|
|
359
403
|
}
|
|
360
404
|
]
|
|
361
405
|
}
|