html-webpack-plugin not inject js file into index.html when using webpack-dev-server

前端 未结 3 806
悲哀的现实
悲哀的现实 2021-02-03 11:51

Here is my webpack config :

var path = require(\'path\');
var webpack = require(\'webpack\')
var HtmlWebpackPlugin = require(\'html-webpack-plugin\')
var fs = re         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 12:48

    You can try config like this..

    new HtmlWebpackPlugin({
          filename: 'index.html',
          template: 'index.html',
          inject: true
        })
    

    and Index.html

    
    
    
      
      
      
      My App
    
    
    

    You will need install npm i -D html-webpack-plugin vue-loader vue-html-loader

    but I recommend you create a project from template, vue init webpack

    This template use the html-webpack-plugin

提交回复
热议问题