-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: using serve/watch, after a partial file is modified all entry p…
…oint templates will be rebuilt, #127
- Loading branch information
Showing
34 changed files
with
326 additions
and
34 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
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
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
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
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
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
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 |
---|---|---|
|
@@ -47,7 +47,7 @@ module.exports = { | |
}, | ||
|
||
hotUpdate: true, // test this option | ||
minify: true, | ||
//minify: true, | ||
}), | ||
], | ||
|
||
|
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,7 @@ | ||
root = true | ||
|
||
[*.html] | ||
insert_final_newline = true | ||
|
||
[*.hbs] | ||
insert_final_newline = true |
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,17 @@ | ||
{ | ||
"articleTitle": "Fruits #: 123", | ||
"articles": [ | ||
{ | ||
"name": "apple", | ||
"price": "0.99 €" | ||
}, | ||
{ | ||
"name": "kiwi", | ||
"price": "1.09 €" | ||
}, | ||
{ | ||
"name": "cocos", | ||
"price": "3.29 €" | ||
} | ||
] | ||
} |
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", | ||
"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 @@ | ||
console.log('>> about.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 @@ | ||
console.log('>> home.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 @@ | ||
console.log('>> main.js'); |
14 changes: 14 additions & 0 deletions
14
test/manual/watch-hbs-partials-multipage/src/views/about.hbs
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,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>About</title> | ||
<script src="../scripts/main.js" defer="defer"></script> | ||
<script src="../scripts/about.js" defer="defer"></script> | ||
</head> | ||
<body> | ||
<h1>About</h1> | ||
{{> header }} | ||
<p>About content</p> | ||
{{> footer }} | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
test/manual/watch-hbs-partials-multipage/src/views/contact.hbs
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> | ||
<head> | ||
<title>Contact</title> | ||
</head> | ||
<body> | ||
<h1>Contact</h1> | ||
<p>Contact content</p> | ||
{{> footer }} | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
test/manual/watch-hbs-partials-multipage/src/views/home.hbs
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,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Home</title> | ||
<script src="../scripts/main.js" defer="defer"></script> | ||
<script src="../scripts/home.js" defer="defer"></script> | ||
</head> | ||
<body> | ||
<h1>Home</h1> | ||
{{> header }} | ||
<p>Home content</p> | ||
{{> footer }} | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/manual/watch-hbs-partials-multipage/src/views/partials/footer.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 @@ | ||
<div>Footer</div> |
1 change: 1 addition & 0 deletions
1
test/manual/watch-hbs-partials-multipage/src/views/partials/header.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 @@ | ||
<h2>Header</h2> |
67 changes: 67 additions & 0 deletions
67
test/manual/watch-hbs-partials-multipage/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,67 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin'); | ||
|
||
module.exports = { | ||
//mode: 'production', | ||
mode: 'development', | ||
//stats: 'minimal', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
verbose: true, | ||
|
||
// TODO: test separate with filesystem cache | ||
// cache: { | ||
// type: 'filesystem', | ||
// }, | ||
|
||
// issue: https://github.com/webdiscus/html-bundler-webpack-plugin/issues/127 | ||
// TODO: fix watch changes in partials | ||
// - in production mode all changes works fine | ||
// - in development mode changes works only in entry template and in a partial only after 1st change | ||
// - changes anywhere works only for last entry | ||
entry: [ | ||
{ | ||
import: 'src/views/home.hbs', | ||
filename: 'index.html', | ||
}, | ||
{ | ||
import: 'src/views/about.hbs', | ||
filename: 'about.html', | ||
}, | ||
{ | ||
import: 'src/views/contact.hbs', | ||
filename: 'contact.html', | ||
}, | ||
], | ||
|
||
js: { | ||
filename: 'js/[name].[contenthash:8].js', | ||
}, | ||
|
||
preprocessor: 'handlebars', | ||
preprocessorOptions: { | ||
partials: ['src/views/partials'], | ||
}, | ||
|
||
hotUpdate: true, | ||
}), | ||
], | ||
|
||
// enable live reload | ||
devServer: { | ||
static: { | ||
directory: path.join(__dirname, 'dist'), | ||
}, | ||
watchFiles: { | ||
paths: ['src/**/*.*', 'data-global.json'], | ||
options: { | ||
usePolling: true, | ||
}, | ||
}, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"type": "JSON" | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
p Hello Pug! | ||
p Hello Pug! |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// SCSS | ||
h1 { | ||
color: #C21F39; | ||
} | ||
color: #c21f39; | ||
} |
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 @@ | ||
h1 Hello World! |
Oops, something went wrong.