To begin, you'll need to install html-template-module-loader
:
$ npm install html-template-module-loader --save-dev
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.html$/i,
use: [
{
loader: 'html-template-module-loader',
options: {
tag: 'tpl',
attr: 'file',
tplTag: 'template',
tplAttr: 'tpl'
}
},
],
},
],
},
};
example
// template: example-tpl.html
<template tpl>
模版
</template>
// html
<tpl file="./src/tpl/example-tpl.html"></tpl>