美文网首页webpack4
webpack构建Vue+ElementUI单页面应用(3)——

webpack构建Vue+ElementUI单页面应用(3)——

作者: 放游 | 来源:发表于2018-08-21 12:25 被阅读0次

第一篇文章package.json中我们配置的scripts有webpack-dev-server,下面开始配置webpack-dev-server,

  • 安装webpack-dev-server

npm i webpack-dev-server -D
  • 配置webpack.dev.conf.js

module.exports = {
   devServer: {
      contentBase: path.resolve(__dirname, "../dist"), //网站的根目录为 根目录/dist,这个路径一般与output.path一致,因为html插件生成的html5页是放在output.path这个目录下
      port: 9000, //端口改为9000
      open:true, // 自动打开浏览器,每次启动服务器会自动打开默认的浏览器
      index:'index.html', // 与HtmlWebpackPlugin中配置filename一样
      inline:true, // 默认为true, 意思是,在打包时会注入一段代码到最后的js文件中,用来监视页面的改动而自动刷新页面,当为false时,网页自动刷新的模式是iframe,也就是将模板页放在一个frame中
      hot:false,
      compress:true //压缩
    }
}

相关文章

网友评论

    本文标题:webpack构建Vue+ElementUI单页面应用(3)——

    本文链接:https://www.haomeiwen.com/subject/lfidiftx.html