Skip to content

Commit e925050

Browse files
authored
Simplify webpack config using html-bundler-webpack-plugin (#415)
1 parent 78baf74 commit e925050

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

examples/src/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
1010
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
1111
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Roboto">
12-
<link rel="stylesheet" href="style.css">
12+
<link rel="stylesheet" href="./scss/style.scss">
1313

1414
<!-- Global site tag (gtag.js) - Google Analytics -->
1515
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-133457161-1"></script>
@@ -107,6 +107,6 @@ <h2>Filter Example</h2>
107107
</footer>
108108
</section>
109109

110-
<script src="index.js"></script>
110+
<script src="./index.jsx"></script>
111111
</body>
112112
</html>

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@
6767
"eslint-plugin-react": "^7.10.0",
6868
"eslint-plugin-react-hooks": "^4.2.0",
6969
"global-jsdom": "^8.6.0",
70-
"html-webpack-plugin": "^5.5.0",
70+
"html-bundler-webpack-plugin": "^1.6.5",
7171
"jsdom": "^21.0.0",
7272
"less": "^4.1.3",
73-
"mini-css-extract-plugin": "^2.7.2",
7473
"mocha": "^10.0.0",
7574
"postcss": "^8.4.21",
7675
"postcss-cli": "^10.1.0",
@@ -83,7 +82,6 @@
8382
"webpack": "^5.3.2",
8483
"webpack-cli": "^5.0.1",
8584
"webpack-dev-server": "^4.11.1",
86-
"webpack-remove-empty-scripts": "^1.0.1",
8785
"webpack-stream": "^7.0.0"
8886
},
8987
"dependencies": {

webpack.config.test.js

+12-19
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
const HtmlWebpackPlugin = require('html-webpack-plugin');
1+
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
22
const path = require('node:path');
3-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4-
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
53

64
module.exports = {
75
mode: 'development',
8-
entry: {
9-
index: path.join(__dirname, 'examples/src/index.jsx'),
10-
style: path.join(__dirname, 'examples/src/scss/style.scss'),
11-
},
126
output: {
137
path: path.join(__dirname, 'examples/dist'),
14-
filename: '[name].js',
158
library: {
169
name: 'ReactCheckboxTree',
1710
type: 'umd',
@@ -33,7 +26,6 @@ module.exports = {
3326
{
3427
test: /\.s[ac]ss$/i,
3528
use: [
36-
MiniCssExtractPlugin.loader,
3729
'css-loader',
3830
'sass-loader',
3931
],
@@ -48,15 +40,16 @@ module.exports = {
4840
watchFiles: ['src/**/*', 'examples/src/**/*'],
4941
},
5042
plugins: [
51-
new RemoveEmptyScriptsPlugin({}),
52-
new MiniCssExtractPlugin({
53-
filename: '[name].css',
54-
}),
55-
new HtmlWebpackPlugin({
56-
template: 'examples/src/index.html',
57-
filename: 'index.html',
58-
inject: false,
59-
minify: false,
60-
}),
43+
new HtmlBundlerPlugin({
44+
entry: {
45+
index: 'examples/src/index.html',
46+
},
47+
js: {
48+
filename: '[name].[contenthash:8].js',
49+
},
50+
css: {
51+
filename: '[name].[contenthash:8].css',
52+
}
53+
}),
6154
],
6255
};

0 commit comments

Comments
 (0)