@oroinc/oro-webpack-config-builder 6.1.0-lts08 → 6.1.0-lts09
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');
|
|
@@ -283,7 +285,8 @@ class ConfigBuilder {
|
|
|
283
285
|
output: {
|
|
284
286
|
filename: '[name].js',
|
|
285
287
|
// Because we use third party libraries 'chunkFilename' should include only [name]
|
|
286
|
-
chunkFilename: this._getVersionedPath('chunk/[name].js', this.assetVersion)
|
|
288
|
+
chunkFilename: this._getVersionedPath('chunk/[name].js', this.assetVersion),
|
|
289
|
+
crossOriginLoading: "anonymous"
|
|
287
290
|
},
|
|
288
291
|
devtool: !env.skipSourcemap && 'inline-cheap-module-source-map',
|
|
289
292
|
mode: 'development',
|
|
@@ -352,6 +355,10 @@ class ConfigBuilder {
|
|
|
352
355
|
new webpack.optimize.MinChunkSizePlugin({
|
|
353
356
|
minChunkSize: 30000 // Minimum number of characters
|
|
354
357
|
}),
|
|
358
|
+
new SubresourceIntegrityPlugin(),
|
|
359
|
+
new IntegrityFilePlugin({
|
|
360
|
+
publicPath: this.resolvedPublicPath
|
|
361
|
+
}),
|
|
355
362
|
new AfterWebpackLogsPlugin(
|
|
356
363
|
stats => this.emitter.emit('build:complete', stats)
|
|
357
364
|
)
|
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-lts09",
|
|
4
4
|
"author": "Oro, Inc. (https://oroinc.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An integration of OroPlatform based applications with the Webpack.",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"webpack-cli": "~6.0.0",
|
|
50
50
|
"webpack-dev-server": "^5.2.0",
|
|
51
51
|
"webpack-merge": "~5.8.0",
|
|
52
|
+
"webpack-subresource-integrity": "^5.2.0-rc.1",
|
|
52
53
|
"wildcard": "~2.0.0"
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -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;
|
|
@@ -3,16 +3,16 @@ const BaseError = require('./base-error');
|
|
|
3
3
|
class SvgIconsSchemaError extends BaseError {
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
|
-
* Invalid
|
|
7
|
-
* has an unknown property '
|
|
8
|
-
* at default/
|
|
6
|
+
* Invalid Theme config: the "theme.yml" files in the "default" theme do not match the API schema.
|
|
7
|
+
* has an unknown property 'label'.
|
|
8
|
+
* at default/theme.yml
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* Invalid
|
|
12
|
-
* misses the property '
|
|
11
|
+
* Invalid Theme config: the "theme.yml" files in the "default" theme do not match the API schema.
|
|
12
|
+
* misses the property 'label'.
|
|
13
13
|
* List of processed files for the "default" theme:
|
|
14
|
-
* /default/
|
|
15
|
-
* /default/
|
|
14
|
+
* /default/theme.yml
|
|
15
|
+
* /default/theme.yml
|
|
16
16
|
*
|
|
17
17
|
* @param {string} reason
|
|
18
18
|
* @param {Array} files
|