diff --git a/package-lock.json b/package-lock.json index 9edcd1c..15fd330 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "cssnano-preset-advanced": "^7.0.0", "firebase-tools": "^13.0.0", "html-inline-css-webpack-plugin": "^1.11.1", + "html-inline-script-webpack-plugin": "^3.2.1", "html-loader": "^5.1.0", "html-minifier": "^4.0.0", "html-minimizer-webpack-plugin": "^3.5.0", @@ -8247,6 +8248,21 @@ "html-webpack-plugin": "^3.0.0 || ^4.0.0 || ^5.0.0" } }, + "node_modules/html-inline-script-webpack-plugin": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/html-inline-script-webpack-plugin/-/html-inline-script-webpack-plugin-3.2.1.tgz", + "integrity": "sha512-PEj9Ve31BE0dva6eTD6wHMOztgIdPxF6gx3wad7ohBkCn7MXpuUvPC9t5ThMJ2NrVi1jWGBYU76DfoS+8dabRw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0", + "npm": ">=6.0.0" + }, + "peerDependencies": { + "html-webpack-plugin": "^5.0.0", + "webpack": "^5.0.0" + } + }, "node_modules/html-loader": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/html-loader/-/html-loader-5.1.0.tgz", @@ -21693,6 +21709,13 @@ "tslib": "^2.6.0" } }, + "html-inline-script-webpack-plugin": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/html-inline-script-webpack-plugin/-/html-inline-script-webpack-plugin-3.2.1.tgz", + "integrity": "sha512-PEj9Ve31BE0dva6eTD6wHMOztgIdPxF6gx3wad7ohBkCn7MXpuUvPC9t5ThMJ2NrVi1jWGBYU76DfoS+8dabRw==", + "dev": true, + "requires": {} + }, "html-loader": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/html-loader/-/html-loader-5.1.0.tgz", diff --git a/package.json b/package.json index ad77742..63095f0 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "cssnano-preset-advanced": "^7.0.0", "firebase-tools": "^13.0.0", "html-inline-css-webpack-plugin": "^1.11.1", + "html-inline-script-webpack-plugin": "^3.2.1", "html-loader": "^5.1.0", "html-minifier": "^4.0.0", "html-minimizer-webpack-plugin": "^3.5.0", diff --git a/webpack.config.js b/webpack.config.js index c7b8bfc..13eed1b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,6 +9,7 @@ const {htmlWebpackPluginTemplateCustomizer} = require('template-ejs-loader'); const HTMLInlineCSSWebpackPlugin = require("html-inline-css-webpack-plugin").default; const { PurgeCSSPlugin } = require('purgecss-webpack-plugin'); const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin'); +const HtmlInlineScriptWebpackPlugin = require('html-inline-script-webpack-plugin'); const glob = require('glob'); const path = require('path'); @@ -35,14 +36,7 @@ module.exports = { }, { test: /\.ejs/, - use: [ - { - loader: 'html-loader' - }, - { - loader: 'template-ejs-loader', - }, - ], + use: ['html-loader', 'template-ejs-loader'], }, { test: /\.s?[ac]ss$/, @@ -137,8 +131,8 @@ module.exports = { } }), filename: 'index.html', - inject: true, - hash: true, + inject: 'body', + hash: false, minify: { collapseWhitespace: true, removeComments: true, @@ -153,6 +147,9 @@ module.exports = { log: true, }), new HTMLInlineCSSWebpackPlugin(), + new HtmlInlineScriptWebpackPlugin({ + scriptMatchPattern: [/.*\.js?$/], // Match hashed JS files + }), ], optimization: { minimize: true,