我正在做一个有很多不同模板的项目,目前大约有 67 个。每次我对 1 个文件进行更改时,Webpack 都会开始重新编译每个把手模板,这使得它非常慢。
我想知道是否有办法减少工作量/优化速度。
我在 Webpack 中的 Handlebars 工作流程如下所示:
var Handlebars = require('handlebars-webpack-plugin');
....
....
new Handlebars({
entry: path.join(process.cwd(), "src", "layouts", "default.hbs"),
output: path.join(process.cwd(), "dist", "form-template.html"),
data: {title: 'Form template', properties: {partial: 'form-template/index'}},
partials: [
path.join(process.cwd(), "src", "partials", "**/*.hbs")
]
}),
new Handlebars({
entry: path.join(process.cwd(), "src", "layouts", "default.hbs"),
output: path.join(process.cwd(), "dist", "homepage.html"),
data: {title: 'Homepage', properties: {partial: 'homepage/index'}},
partials: [
path.join(process.cwd(), "src", "partials", "**/*.hbs")
]
}),
new Handlebars({
entry: path.join(process.cwd(), "src", "layouts", "default.hbs"),
output: path.join(process.cwd(), "dist", "404.html"),
data: {title: '404 error', properties: {partial: '404/index'}},
partials: [
path.join(process.cwd(), "src", "partials", "**/*.hbs")
]
}),
...
... etc.