可以使用raw-loader
模板html
Document${require('raw-loader!./a.tpl.html')}
${require('raw-loader!./b.tpl.html')}
this is "index.html" own content
webpack配置
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './web/src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name]-[hash].js'
},
plugins: [
new HtmlWebpackPlugin({
title: 'inline_html',
minify: false,
loader: "raw-loader",
template: 'web/src/index.html'
})
]
};
生成的代码html
Documentthis is "a.tpl.html" file content
this is "b.tpl.html" file content
this is "index.html" own content
目录结构