简体   繁体   English

用于 webpack 插件 'html-webpack-plugin' 的 EJS 模板

[英]EJS Template for webpack plugin 'html-webpack-plugin'

I want to load a custom template for the plugin 'html-webpack-plugin'.我想为插件“html-webpack-plugin”加载自定义模板。

I have this index.ejs and this webpack.config.js我有这个index.ejs和这个webpack.config.js

But I have this error when build:但是我在构建时出现这个错误:

ERROR in Error: Child compilation failed: Module build failed: SyntaxError: /Users/saro/Projects/react-starter/app/assets/index.ejs: Unexpected token (1:1)错误中的错误:子编译失败:模块构建失败:语法错误:/Users/saro/Projects/react-starter/app/assets/index.ejs:意外令牌(1:1)

1 | <!DOCTYPE html>

first, install the loader:首先,安装加载器:

npm install ejs-loader --save-dev

then update your webpack.config.js (add ejs! ):然后更新你的 webpack.config.js(添加ejs! ):

  plugins: [
    new HtmlwebpackPlugin({
      title: 'React Starter Kit',
      hash: true,
      inject: false,
      appMountId: 'app',
      template: 'ejs!app/assets/index.ejs'
    })
  ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM