Webpack.config how to just copy the index.html to the dist folder

后端 未结 9 1769
醉梦人生
醉梦人生 2020-12-07 08:14

I am trying to automate assets going into /dist. I have the following config.js:

module.exports = {
  context: __dirname + "/lib",
  entry: {
    m         


        
9条回答
  •  余生分开走
    2020-12-07 09:06

    Option 1

    In your index.js file (i.e. webpack entry) add a require to your index.html via file-loader plugin, e.g.:

    require('file-loader?name=[name].[ext]!../index.html');

    Once you build your project with webpack, index.html will be in the output folder.

    Option 2

    Use html-webpack-plugin to avoid having an index.html at all. Simply have webpack generate the file for you.

提交回复
热议问题