美文网首页
vue.config.js设置

vue.config.js设置

作者: 码农界四爷__King | 来源:发表于2021-05-27 16:23 被阅读0次
'use strict'


const path = require('path')

module.exports = {
  dev: {
    assetsSubDirectory: 'static',//指的是静态资源文件夹,默认“static”
    assetsPublicPath: '/',//指的是发布路径
    proxyTable: {//是我们常用来配置代理API的地方
      '/user': {
        target: 'http://www.abc.com', //目标接口域名
        changeOrigin: true, //是否跨域
       /* pathRewrite: {
          '^/api': '/abc' //重写接口:把请求地址值中的/api改成/abc
        } */
      },
    },

    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8080, //端口号
    autoOpenBrowser: false,//是否自动打开浏览器
    errorOverlay: true,//查询错误
    notifyOnErrors: true,//通知错误
    poll: false, // 是跟devserver相关的一个配置,webpack为我们提供的devserver是可以监控文件改动的,但在有些情况下却不能工作,我们可以设置一个轮询(poll)来解决

    useEslint: true,//是否使用eslint(是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确、风格统一的代码)
    showEslintErrorsInOverlay: false,//是否展示eslint的错误提示

    devtool: 'eval-source-map',
    cacheBusting: true,
    cssSourceMap: false,
  },

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),//编译后index.html的路径,path.resolve(__dirname, ‘…/dist’)中

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),//打包后的文件根路径,至于assetsSubDirectory和assetsPublicPath跟dev中的一样
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',

    /**
     * Source Maps
     */

    productionSourceMap: true,//是否开启source-map
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',//同dev

    productionGzip: false,//是否压缩
    productionGzipExtensions: ['js', 'css'],//gzip模式下需要压缩的文件的扩展名,设置后会对相应扩展名的文件进行压缩

    bundleAnalyzerReport: process.env.npm_config_report//是否开启打包后的分析报告
  }
}

相关文章

网友评论

      本文标题:vue.config.js设置

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