目前正在使用:
“ webpack”:“ ^ 2.4.1”
“角度”:“ ^ 1.6.3”
当前使用中出现的错误是我需要适当的加载器:
var root = {
template: require('./root.html')
};
{
test: /\*.html$/,
use: 'raw-loader!html-minifier-loader',
exclude: /node_modules/
}
但是,如果我执行以下任一操作,则可以正常加载:
var root = {
templateUrl: './root.html'
};
var root = {
template: require('raw-loader!./root.html')
};
如果我需要HTML文件,是否必须专门内联使用加载程序?我以为这就是webpack配置中的加载程序的用途,除非我不知道Webpack 2的更改。
最佳答案
您的test condition不正确。仅当文件名确实包含*
时,它才会匹配,例如:
root*.html
root*ahtml
root*bhtml
你要
/\.html$/
代替。这是一个正则表达式,而不是全局模式。