vue脚手架4 ,vue.config.js的简单配置

module.exports = {

  runtimeCompiler: true, // 运行时编译器的 Vue 构建版本。设置为 true 后你就可以在 Vue 组件中使用 template 选项了,但是这会让你的应用额外增加 10kb 左右。

  lintOnSave: false, // 关闭ESLint编译

  chainWebpack: config => {//热替换

    // 修复HMR

    config.resolve.symlinks(true);

  },

  configureWebpack : {

    resolve: {

      extensions: ['.js', '.vue', '.json'],//可不写的扩展名

      alias: {//设置文件查找路径

        'vue$': 'vue/dist/vue.esm.js',

        '@': resolve('src'),

        'components': resolve('src/components'),

      }

    },

  },

  css: { // CSS 相关的 loader 传递选项

    loaderOptions: {

      postcss: {

        plugins: [


        ]

      }

    }

  },

  devServer: {

    proxy: {//如果你的前端应用和后端 API 服务器没有运行在同一个主机上,你需要在开发环境下将 API 请求代理到 API 服务器。

      '/api': {//解决跨域问题

        target: 'http://localhost:4000',//代理服务器

        changeOrigin: true,

        pathRewrite: {

          '^/api': ''

        }

      }

    }

  },


}

你可能感兴趣的:(vue脚手架4 ,vue.config.js的简单配置)