2017-09-07 6 views
2

webpackを使用して、ejsを使用してHTMLページを再構成しようとしています。 以下の設定でエラーが表示されます。ejsローダーを使用したwebpack

Module build failed: SyntaxError: Unexpected token .

webpack.config.js

const webpack = require('webpack'); 
const HtmlWebpackPlugin = require('html-webpack-plugin'); 


module.exports = { 
    context: __dirname + "/src", 
    entry: ['./pages/index.ejx'], 
    output: { 
      path: __dirname + "/dist", 
      filename: "[name].bundle.js", 
      chunkFilename: "[id].bundle.js"   
    }, 
    plugins: [ 
     new HtmlWebpackPlugin({ template: 'pages/index.ejs'}) 
    ] 
} 

index.ejs

<!DOCTYPE html> 
<html> 
    <% include ..partials/head %> 

    <% include ..partials/body %> 
</html> 

答えて

1

この設定は、これまでに動作するようです:

const webpack = require('webpack'); 
const HtmlWebpackPlugin = require('html-webpack-plugin'); 


module.exports = { 
    context: __dirname + "/src", 
    entry: ['./index.ejs'], 
    output: { 
      path: __dirname + "/dist", 
      filename: "[name].bundle.js", 
      chunkFilename: "[id].bundle.js"   
    }, 
    module: { 
     rules: [ 
      { test: /\.ejs$/, loader: "ejs-render-loader" } 

     ] 
    }, 
     plugins: [ 
      new HtmlWebpackPlugin({ 
       template: 'index.ejs' 
      }) 
     ] 
} 
関連する問題