diff --git a/webpack.config.js b/webpack.config.js index d080f325..849be556 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,13 +1,96 @@ const path = require('path'); +const crypto = require('crypto'); +const zlib = require('zlib'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const CompressionPlugin = require('compression-webpack-plugin'); -const zlib = require('zlib'); + +/** + * Computes the SHA-384 hash of bootstrap-shell.js and injects a build-time + * `; + } else { + importMapScript = ``; + } + + let html; + if (existingMapMatch) { + // Replace the existing importmap in-place + html = htmlSource.replace(existingMapMatch[0], importMapScript); + } else { + html = htmlSource.replace('', ` ${importMapScript}\n`); + } + compilation.updateAsset('index.html', new compiler.webpack.sources.RawSource(html)); + } + ); + }); + } +} module.exports = (env, argv) => { const pluginsToAdd = []; const webpackMode = argv.mode; + pluginsToAdd.push(new BootstrapShellSRIPlugin()); + pluginsToAdd.push( new HtmlWebpackPlugin({ template: './src/index.html',