我想加载插件“html-webpack-plugin”的自定义模板。
我有这个index.ejs 还有这个webpack.config.js
但是我在构建时遇到此错误:
ERROR in Error: Child compilation failed: Module build failed: SyntaxError: /Users/saro/Projects/react-starter/app/assets/index.ejs: Unexpected token (1:1)
1 | <!DOCTYPE html>
最佳答案
首先,安装加载器:
npm install ejs-loader --save-dev
然后更新您的 webpack.config.js(添加 ejs!
):
plugins: [
new HtmlwebpackPlugin({
title: 'React Starter Kit',
hash: true,
inject: false,
appMountId: 'app',
template: 'ejs!app/assets/index.ejs'
})
]
关于javascript - webpack插件的EJS模板 'html-webpack-plugin',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35323468/