从html到pug模板,将变量从html-webpack-plugin传递到pug模板
是否可以將變量傳遞給我之前在'html-webpack-plugin'中定義的'pug-html-loader'加載的.pug模板?
webpack.config.babel.js
...
{
test: /\.pug$/,
use: [
{
loader: 'html-loader'
},
{
loader: 'pug-html-loader',
options: {
self: true
}
}]
}
...
plugins: [
new HtmlWebpackPlugin({
chunks: ['index'],
filename: 'index.html',
template: './src/templates/layout.pug',
title: 'Welcome',
file: 'index'
}),
new HtmlWebpackPlugin({
chunks: ['index', 'contact'],
filename: 'contact.html',
template: './src/templates/layout.pug',
title: 'Contact us',
file: 'contact'
}),
]
在layout.html中,我定義如下:
${ require('html-loader!../partials/' + htmlWebpackPlugin.options.file + '.html' ) }
如何使用它來傳遞所有變量 - 在Webpack插件中定義我的PugTemplates和文件中的用法?該應用程序應該是一個簡單的創建簡單網頁的過程,它由幾個靜態頁面組成。
總結
以上是生活随笔為你收集整理的从html到pug模板,将变量从html-webpack-plugin传递到pug模板的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实现物联网项目,你需要提前知道的6件事情
- 下一篇: linux系统中使用pycharn,在p