2
votes

I want to load a custom template for the plugin 'html-webpack-plugin'.

I have this index.ejs and this 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)

1 | <!DOCTYPE html>

1
aren't you missing the ejs loader ? or at least an html loader ? - topheman
@topheman how do i configre my webpack with ejs loader? - SaroVin

1 Answers

2
votes

first, install the loader:

npm install ejs-loader --save-dev

then update your webpack.config.js (add ejs!):

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