Webpack 带网页包的多步骤组装
任务:Webpack 带网页包的多步骤组装,webpack,pug,Webpack,Pug,任务: 将所有pug文件(blocks/*.pug)合并为一个(blocks.pug) 编译包含blocks.pug的index.pug 一切正常,但有个问题。 程序集运行速度太快,以至于没有时间读取创建的blocks.pug文件: 模块生成失败:错误:enoint:没有这样的文件或目录,请打开blocks.pug 因此,我必须再次运行程序集以避免此错误,并获得正确的index.html 有没有办法一次完成所有这些步骤 My webpack.config.js const ExtractText
const ExtractTextPlugin = require('extract-text-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin');
let extractPug = new ExtractTextPlugin({filename: '../src/blocks/blocks.pug', allChunks: true});
module.exports = {
...
module: {
rules: [{
enforce: 'pre',
test: /\.pug$/,
exclude: /\/blocks\/index.pug$/,
loader: extractPug.extract('raw')
}, {
test: /\.pug$/,
include: /\/blocks\/index.pug$/,
loader: 'html!pug-html?pretty'
},
...
]
},
plugins: [
extractPug,
new HtmlWebpackPlugin({
filename: 'index.html',
template: './blocks/index.pug',
inject: 'body'
})
]
};
对不起,如果我写了不清楚的东西,我的英语不够好