-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add serv mode test for change imported js file
- Loading branch information
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"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.", | ||
"scripts": { | ||
"start": "webpack serve --mode development", | ||
"watch": "webpack watch --mode development", | ||
"build": "webpack --mode=production --progress" | ||
}, | ||
"devDependencies": { | ||
"html-bundler-webpack-plugin": "file:../../.." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Home</title> | ||
<script src="./main.js" defer="defer"></script> | ||
</head> | ||
<body> | ||
<h1>Hello World!</h1> | ||
<p>Change the content of an imported JS file.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// test in serv mode: change the content of the imported file | ||
import str from './module'; | ||
|
||
console.log('>> main', { str }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'Test 123'; |
43 changes: 43 additions & 0 deletions
43
test/manual/watch-dependencies-import-js/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
stats: 'minimal', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
// auto processing templates in the path | ||
entry: { | ||
index: './src/index.html', | ||
}, | ||
|
||
// test: configure paths to watch file changes | ||
// watchFiles: { | ||
// paths: ['./src'], | ||
// //files: [/\.(html|js|sc?ss)$/], | ||
// //ignore: [], | ||
// }, | ||
|
||
verbose: true, | ||
}), | ||
], | ||
|
||
// enable live reload | ||
devServer: { | ||
//hot: false, | ||
static: { | ||
directory: path.join(__dirname, 'dist'), | ||
}, | ||
watchFiles: { | ||
paths: ['src/**/*.*'], | ||
options: { | ||
usePolling: true, | ||
}, | ||
}, | ||
}, | ||
}; |