Skip to content

Commit 3a405ec

Browse files
authored
chore: Inlining javascript (#34)
1 parent 8c4d5d4 commit 3a405ec

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"cssnano-preset-advanced": "^7.0.0",
2525
"firebase-tools": "^13.0.0",
2626
"html-inline-css-webpack-plugin": "^1.11.1",
27+
"html-inline-script-webpack-plugin": "^3.2.1",
2728
"html-loader": "^5.1.0",
2829
"html-minifier": "^4.0.0",
2930
"html-minimizer-webpack-plugin": "^3.5.0",

webpack.config.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {htmlWebpackPluginTemplateCustomizer} = require('template-ejs-loader');
99
const HTMLInlineCSSWebpackPlugin = require("html-inline-css-webpack-plugin").default;
1010
const { PurgeCSSPlugin } = require('purgecss-webpack-plugin');
1111
const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin');
12+
const HtmlInlineScriptWebpackPlugin = require('html-inline-script-webpack-plugin');
1213

1314
const glob = require('glob');
1415
const path = require('path');
@@ -35,14 +36,7 @@ module.exports = {
3536
},
3637
{
3738
test: /\.ejs/,
38-
use: [
39-
{
40-
loader: 'html-loader'
41-
},
42-
{
43-
loader: 'template-ejs-loader',
44-
},
45-
],
39+
use: ['html-loader', 'template-ejs-loader'],
4640
},
4741
{
4842
test: /\.s?[ac]ss$/,
@@ -137,8 +131,8 @@ module.exports = {
137131
}
138132
}),
139133
filename: 'index.html',
140-
inject: true,
141-
hash: true,
134+
inject: 'body',
135+
hash: false,
142136
minify: {
143137
collapseWhitespace: true,
144138
removeComments: true,
@@ -153,6 +147,9 @@ module.exports = {
153147
log: true,
154148
}),
155149
new HTMLInlineCSSWebpackPlugin(),
150+
new HtmlInlineScriptWebpackPlugin({
151+
scriptMatchPattern: [/.*\.js?$/], // Match hashed JS files
152+
}),
156153
],
157154
optimization: {
158155
minimize: true,

0 commit comments

Comments
 (0)