Commit 2af5239a authored by Evaryont's avatar Evaryont

webpack subresource integrity added

parent 138dc055
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;;
const SriPlugin = require('webpack-subresource-integrity');
module.exports = {
entry: {
......@@ -8,7 +9,8 @@ module.exports = {
},
output: {
"path": __dirname+'/build/assets/',
"filename": "[name].js"
"filename": "[name].js",
"crossOriginLoading": "anonymous"
},
devtool: "source-map",
module: {
......@@ -43,6 +45,34 @@ module.exports = {
},
plugins: [
new MiniCssExtractPlugin({filename: "[name].css"}),
new StatsWriterPlugin()
new SriPlugin({
hashFuncNames: ['sha256', 'sha384'],
enabled: true, // process.env.NODE_ENV === 'production',
}),
new StatsWriterPlugin({
filename: 'stats.json',
fields: null,
transform: (data, comp) => {
stats = comp.compiler.getStats()
var output = {
concerns: {
warnings: stats.hasWarnings(),
errors: stats.hasErrors()
}
};
output.assetsByChunkName = data.assetsByChunkName;
output.integrity = {}
for (let chunk of Object.keys(output.assetsByChunkName)) {
integrity_list = {}
for (let asset_name of output.assetsByChunkName[chunk]) {
integrity_list[asset_name] = stats.compilation.assets[asset_name].integrity;
}
output.integrity[chunk] = integrity_list
}
return JSON.stringify(output, null, 4);
}
})
]
}
......@@ -5138,6 +5138,13 @@ webpack-stats-plugin@^0.2.1:
resolved "https://registry.yarnpkg.com/webpack-stats-plugin/-/webpack-stats-plugin-0.2.1.tgz#1f5bac13fc25d62cbb5fd0ff646757dc802b8595"
integrity sha512-OYMZLpZrK/qLA79NE4kC4DCt85h/5ipvWJcsefKe9MMw0qU4/ck/IJg+4OmWA+5EfrZZpHXDq92IptfYDWVfkw==
webpack-subresource-integrity@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/webpack-subresource-integrity/-/webpack-subresource-integrity-1.3.0.tgz#5cc0729a78593ad7e2088cd72d4a8d42ba3bfa9c"
integrity sha512-qR2AwKMOjqOSsk4cTuZlRjYXfvAo7/FreL44AG5R5Vn7qHAE78BOdbPPVk9fZonMIiSKYQsIO2aC61JVJC60AQ==
dependencies:
webpack-sources "^1.3.0"
webpack@^4.26.1:
version "4.26.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.26.1.tgz#ff3a9283d363c07b3494dfa702d08f4f2ef6cb39"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment