@oroinc/oro-webpack-config-builder 5.1.0-lts010 → 5.1.0-lts012
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/oro-webpack-config.js
CHANGED
|
@@ -9,6 +9,8 @@ const EntryPointFileWriter = require('./writer/scss-entry-point-file-writer');
|
|
|
9
9
|
const LayoutModulesConfigLoader = require('./modules-config/layout-modules-config-loader');
|
|
10
10
|
const LayoutStyleLoader = require('./style/layout-style-loader');
|
|
11
11
|
const MapModulesPlugin = require('./plugin/map/map-modules-plugin');
|
|
12
|
+
const IntegrityFilePlugin = require('./plugin/integrity/integrity-file-plugin');
|
|
13
|
+
const {SubresourceIntegrityPlugin} = require('webpack-subresource-integrity');
|
|
12
14
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
13
15
|
const ModulesConfigLoader = require('./modules-config/modules-config-loader');
|
|
14
16
|
const DynamicImportsFileWriter = require('./writer/dynamic-imports-file-writer');
|
|
@@ -26,6 +28,7 @@ const RtlCssWebpackPlugin = require('rtlcss-webpack-plugin');
|
|
|
26
28
|
const validation = require('./validation');
|
|
27
29
|
const EventEmitter = require('events');
|
|
28
30
|
const ErrorHandler = require('./error-handler');
|
|
31
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
29
32
|
|
|
30
33
|
require('resolve-url-loader');
|
|
31
34
|
|
|
@@ -279,7 +282,8 @@ class ConfigBuilder {
|
|
|
279
282
|
output: {
|
|
280
283
|
filename: '[name].js',
|
|
281
284
|
// Because we use third party libraries 'chunkFilename' should include only [name]
|
|
282
|
-
chunkFilename: this._getVersionedPath('chunk/[name].js', this.assetVersion)
|
|
285
|
+
chunkFilename: this._getVersionedPath('chunk/[name].js', this.assetVersion),
|
|
286
|
+
crossOriginLoading: "anonymous"
|
|
283
287
|
},
|
|
284
288
|
devtool: !env.skipSourcemap && 'inline-cheap-module-source-map',
|
|
285
289
|
mode: 'development',
|
|
@@ -289,7 +293,20 @@ class ConfigBuilder {
|
|
|
289
293
|
cacheGroups: {
|
|
290
294
|
defaultVendors: false
|
|
291
295
|
}
|
|
292
|
-
}
|
|
296
|
+
},
|
|
297
|
+
minimize: this._isProduction,
|
|
298
|
+
minimizer: [new TerserPlugin({
|
|
299
|
+
parallel: true,
|
|
300
|
+
extractComments: false,
|
|
301
|
+
minify: TerserPlugin.swcMinify,
|
|
302
|
+
terserOptions: {
|
|
303
|
+
compress: true,
|
|
304
|
+
mangle: true,
|
|
305
|
+
format: {
|
|
306
|
+
comments: false
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
})]
|
|
293
310
|
},
|
|
294
311
|
resolveLoader: {
|
|
295
312
|
modules: [
|
|
@@ -369,6 +386,10 @@ class ConfigBuilder {
|
|
|
369
386
|
new webpack.optimize.MinChunkSizePlugin({
|
|
370
387
|
minChunkSize: 30000 // Minimum number of characters
|
|
371
388
|
}),
|
|
389
|
+
new SubresourceIntegrityPlugin(),
|
|
390
|
+
new IntegrityFilePlugin({
|
|
391
|
+
publicPath: this.resolvedPublicPath
|
|
392
|
+
}),
|
|
372
393
|
new AfterWebpackLogsPlugin(
|
|
373
394
|
stats => this.emitter.emit('build:complete', stats)
|
|
374
395
|
),
|
|
@@ -418,7 +439,10 @@ class ConfigBuilder {
|
|
|
418
439
|
// Additional setting for production mode
|
|
419
440
|
if (this._isProduction) {
|
|
420
441
|
webpackConfig.devtool = false;
|
|
421
|
-
webpackConfig.plugins.push(new CssMinimizerPlugin(
|
|
442
|
+
webpackConfig.plugins.push(new CssMinimizerPlugin({
|
|
443
|
+
parallel: true,
|
|
444
|
+
minify: CssMinimizerPlugin.esbuildMinify
|
|
445
|
+
}));
|
|
422
446
|
}
|
|
423
447
|
|
|
424
448
|
return webpackConfig;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oroinc/oro-webpack-config-builder",
|
|
3
|
-
"version": "5.1.0-
|
|
3
|
+
"version": "5.1.0-lts012",
|
|
4
4
|
"author": "Oro, Inc (https://www.oroinc.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An integration of OroPlatform based applications with the Webpack.",
|
|
7
7
|
"main": "oro-webpack-config.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
+
"@swc/core": "^1.11.8",
|
|
9
10
|
"@babel/core": "~7.21.3",
|
|
10
11
|
"@babel/plugin-transform-runtime": "~7.21.0",
|
|
11
12
|
"@babel/preset-env": "~7.21.2",
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
"deepmerge": "~4.3.1",
|
|
18
19
|
"exports-loader": "~4.0.0",
|
|
19
20
|
"expose-loader": "~4.1.0",
|
|
21
|
+
"esbuild-loader": "^4.3.0",
|
|
20
22
|
"file-loader": "~6.2.0",
|
|
21
23
|
"html-webpack-plugin": "~5.5.0",
|
|
22
24
|
"imports-loader": "~4.0.1",
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
"schema-utils": "^4.0.0",
|
|
36
38
|
"style-loader": "~3.3.1",
|
|
37
39
|
"terser": "~5.17.1",
|
|
40
|
+
"terser-webpack-plugin": "^5.3.13",
|
|
38
41
|
"text-loader": "0.0.1",
|
|
39
42
|
"underscore": "1.13.*",
|
|
40
43
|
"url-loader": "~4.1.1",
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
"webpack-cli": "~5.0.0",
|
|
44
47
|
"webpack-dev-server": "^4.11.1",
|
|
45
48
|
"webpack-merge": "~5.8.0",
|
|
49
|
+
"webpack-subresource-integrity": "^5.2.0-rc.1",
|
|
46
50
|
"wildcard": "~2.0.0"
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { createHash } = require('crypto');
|
|
2
|
+
const { Compilation, sources } = require('webpack');
|
|
3
|
+
const fs = require('fs').promises;
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
class IntegrityFilePlugin {
|
|
7
|
+
constructor({fileName = 'integrity.json', publicPath = '', algorithm = 'sha384'} = {}) {
|
|
8
|
+
this.fileName = fileName;
|
|
9
|
+
this.publicPath = publicPath;
|
|
10
|
+
this.algorithm = algorithm;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
apply(compiler) {
|
|
14
|
+
compiler.hooks.thisCompilation.tap('IntegrityFilePlugin', (compilation) => {
|
|
15
|
+
compilation.hooks.processAssets.tapPromise(
|
|
16
|
+
{ name: 'SubresourceIntegrityPlugin', stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER },
|
|
17
|
+
async () => {
|
|
18
|
+
const integrityData = Object.fromEntries(
|
|
19
|
+
Object.entries(compilation.assets)
|
|
20
|
+
.filter(([assetName]) => assetName.endsWith('.css') || assetName.endsWith('.js'))
|
|
21
|
+
.map(([assetName, asset]) => {
|
|
22
|
+
const hash = createHash(this.algorithm).update(asset.source()).digest('base64');
|
|
23
|
+
const assetNormalized = assetName.split('?')[0];
|
|
24
|
+
|
|
25
|
+
return [
|
|
26
|
+
path.join(compiler.options.output.publicPath || '', assetNormalized),
|
|
27
|
+
`${this.algorithm}-${hash}`
|
|
28
|
+
];
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
const jsonData = JSON.stringify(integrityData, null, 2);
|
|
32
|
+
const outputPath = path.join(this.publicPath, compiler.options.output.publicPath, this.fileName);
|
|
33
|
+
|
|
34
|
+
await fs.writeFile(outputPath, jsonData, 'utf8');
|
|
35
|
+
compilation.emitAsset(outputPath, new sources.RawSource(jsonData));
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = IntegrityFilePlugin;
|