EJS Template for webpack plugin 'html-webpack-plugin'
我想为插件'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 | npm install ejs-loader --save-dev |
然后更新您的webpack.config.js(添加
1 2 3 4 5 6 7 8 9 | plugins: [ new HtmlwebpackPlugin({ title: 'React Starter Kit', hash: true, inject: false, appMountId: 'app', template: 'ejs!app/assets/index.ejs' }) ] |