Skip to content

Commit de779b8

Browse files
committed
test: add serv mode test for change imported js file
1 parent 0114475 commit de779b8

5 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"description": "IMPORTANT: don't install webpack here because the Webpack instance MUST be one, otherwise appear the error: The 'compilation' argument must be an instance of Compilation.",
3+
"scripts": {
4+
"start": "webpack serve --mode development",
5+
"watch": "webpack watch --mode development",
6+
"build": "webpack --mode=production --progress"
7+
},
8+
"devDependencies": {
9+
"html-bundler-webpack-plugin": "file:../../.."
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>Home</title>
5+
<script src="./main.js" defer="defer"></script>
6+
</head>
7+
<body>
8+
<h1>Hello World!</h1>
9+
<p>Change the content of an imported JS file.</p>
10+
</body>
11+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// test in serv mode: change the content of the imported file
2+
import str from './module';
3+
4+
console.log('>> main', { str });
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'Test 123';
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const path = require('path');
2+
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
3+
4+
module.exports = {
5+
mode: 'production',
6+
stats: 'minimal',
7+
8+
output: {
9+
path: path.join(__dirname, 'dist/'),
10+
},
11+
12+
plugins: [
13+
new HtmlBundlerPlugin({
14+
// auto processing templates in the path
15+
entry: {
16+
index: './src/index.html',
17+
},
18+
19+
// test: configure paths to watch file changes
20+
// watchFiles: {
21+
// paths: ['./src'],
22+
// //files: [/\.(html|js|sc?ss)$/],
23+
// //ignore: [],
24+
// },
25+
26+
verbose: true,
27+
}),
28+
],
29+
30+
// enable live reload
31+
devServer: {
32+
//hot: false,
33+
static: {
34+
directory: path.join(__dirname, 'dist'),
35+
},
36+
watchFiles: {
37+
paths: ['src/**/*.*'],
38+
options: {
39+
usePolling: true,
40+
},
41+
},
42+
},
43+
};

0 commit comments

Comments
 (0)