webpack的插件html-webpack-plugin,怎么处理jsp或者ftl(freemarker)文件呢?

new HtmlWebpackPlugin({
  filename: 'index.jsp',
  template: './src/template.jsp'
})

Child html-webpack-plugin for "index.jsp":
     1 asset
       [0] ./node_modules/_html-webpack-plugin@3.2.0@html-webpack-plugin/lib/loader.js!./src/template.jsp
984 bytes {0} [built] [failed] [1 error]

    ERROR in ./node_modules/_html-webpack-plugin@3.2.0@html-webpack-plugin/lib/loader.js!./src/template.jsp
    Module build failed: SyntaxError: Invalid or unexpected token
        at Function (<anonymous>)
        at C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_lodash@4.17.11@lodash\lodash.js:14866:16
        at apply (C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_lodash@4.17.11@lodash\lodash.js:473:27)
        at C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_lodash@4.17.11@lodash\lodash.js:15250:16
        at apply (C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_lodash@4.17.11@lodash\lodash.js:475:27)
        at C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_lodash@4.17.11@lodash\lodash.js:6569:16
        at Function.template (C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_lodash@4.17.11@lodash\lodash.js:14865:20)
        at Object.module.exports (C:\Users\htbst\Desktop\html-webpack-plugin\node_modules\_html-webpack-plugin@3.2.0@html-webpack-plugin\lib\loader.js:28:22)
阅读 5.7k
2 个回答

step1

npm install raw-loader --save-dev

step2

new HtmlWebpackPlugin({
  filename: 'index.jsp',
  template: 'raw-loader!./src/template.jsp'
})

自问自答,6啊

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题