2017-09-04 183 views
1

当Webpack编译包含下面的HTML的应用程序时,它抱怨theme变量未定义。HTML Webpack Plugin不会编译,因为Thymeleaf变量未定义

这里是我的index.html文件:

<!DOCTYPE html> 
<html lang="en" xmlns:th="http://www.thymeleaf.org"> 
<head> 
    <meta charset="UTF-8"/> 
</head> 
<body th:class="${theme}"> 
    <div id="root"></div> 
</body> 
</html> 

这里是我的错误:

Failed to compile. 

Error in Template execution failed: ReferenceError: theme is not defined 

- loader.js:4 eval 
/src/main/resources/templates/index.html?./~/html-webpack-plugin/lib/loader.js:4:10 

回答

0

我也一样错误。我发现this issue和你刚才做的WebPack使用“HTML加载器”是这样的:

new HtmlWebpackPlugin({ 
    template: '!!html-loader!index.html' 
}) 

PS:不要忘了与故宫前安装;)