解析webpack的配置文件webpack.config.js(二)

起服务
npm i webpack-dev-server -D

构建html
npm i html-webpack-plugin -D 快速构建html

const HtmlPlugin=require('html-webpack-plugin')
const webpack=require('webpack');//热更新为内置的
//开发中   插件  webpack-dev-server
devServer:{
    port:9090,//端口
    open:true,//自动打开网页
    hot:true,//启动热更新,
    after(app){//接口
        
    }
}

//插件   进一步操作模块文件
plugins:[
        new HtmlPlugin({
            template:'./index.html',//相对路径  zh找的是模板文件
            filename:'index.html'//生成的html名字
        }),
        new webpack.HotModuleReplacementPlugin()//模块热更新
    ]
    

    
    

猜你喜欢

转载自blog.csdn.net/qq_43201542/article/details/87726711