@oroinc/oro-webpack-config-builder 6.1.0-lts0 → 6.1.0-lts01
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');
|
|
@@ -280,7 +282,8 @@ class ConfigBuilder {
|
|
|
280
282
|
output: {
|
|
281
283
|
filename: '[name].js',
|
|
282
284
|
// Because we use third party libraries 'chunkFilename' should include only [name]
|
|
283
|
-
chunkFilename: this._getVersionedPath('chunk/[name].js', this.assetVersion)
|
|
285
|
+
chunkFilename: this._getVersionedPath('chunk/[name].js', this.assetVersion),
|
|
286
|
+
crossOriginLoading: "anonymous"
|
|
284
287
|
},
|
|
285
288
|
devtool: !env.skipSourcemap && 'inline-cheap-module-source-map',
|
|
286
289
|
mode: 'development',
|
|
@@ -374,6 +377,8 @@ class ConfigBuilder {
|
|
|
374
377
|
new webpack.optimize.MinChunkSizePlugin({
|
|
375
378
|
minChunkSize: 30000 // Minimum number of characters
|
|
376
379
|
}),
|
|
380
|
+
new SubresourceIntegrityPlugin(),
|
|
381
|
+
new IntegrityFilePlugin(),
|
|
377
382
|
new AfterWebpackLogsPlugin(
|
|
378
383
|
stats => this.emitter.emit('build:complete', stats)
|
|
379
384
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oroinc/oro-webpack-config-builder",
|
|
3
|
-
"version": "6.1.0-
|
|
3
|
+
"version": "6.1.0-lts01",
|
|
4
4
|
"author": "Oro, Inc. (https://oroinc.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An integration of OroPlatform based applications with the Webpack.",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"webpack-cli": "~5.0.0",
|
|
47
47
|
"webpack-dev-server": "^4.11.1",
|
|
48
48
|
"webpack-merge": "~5.8.0",
|
|
49
|
+
"webpack-subresource-integrity": "^5.2.0-rc.1",
|
|
49
50
|
"wildcard": "~2.0.0"
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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({ outputPath = 'integrity.json', algorithm = 'sha384' } = {}) {
|
|
8
|
+
this.outputPath = outputPath;
|
|
9
|
+
this.algorithm = algorithm;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply(compiler) {
|
|
13
|
+
compiler.hooks.thisCompilation.tap('IntegrityFilePlugin', (compilation) => {
|
|
14
|
+
compilation.hooks.processAssets.tapPromise(
|
|
15
|
+
{ name: 'SubresourceIntegrityPlugin', stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER },
|
|
16
|
+
async () => {
|
|
17
|
+
const integrityData = Object.fromEntries(
|
|
18
|
+
Object.entries(compilation.assets).map(([assetName, asset]) => {
|
|
19
|
+
const hash = createHash(this.algorithm).update(asset.source()).digest('base64');
|
|
20
|
+
const assetNormalized = assetName.split('?')[0];
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
path.join(compiler.options.output.publicPath || '', assetNormalized),
|
|
24
|
+
`${this.algorithm}-${hash}`
|
|
25
|
+
];
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const jsonData = JSON.stringify(integrityData, null, 2);
|
|
30
|
+
await fs.writeFile(this.outputPath, jsonData, 'utf8');
|
|
31
|
+
compilation.emitAsset(this.outputPath, new sources.RawSource(jsonData));
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = IntegrityFilePlugin;
|