123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- const { defineConfig } = require('@vue/cli-service')
- const time = new Date().getTime();
- module.exports = defineConfig({
- productionSourceMap: false,
- // 执行 npm run build 统一配置文件路径(本地访问dist/index.html需'./')
- // NODE_ENV:Node.js 暴露给执行脚本的系统环境变量。通常用于确定在开发环境还是生产环境
- publicPath: './',
- outputDir: 'dist', // 输出文件目录
- assetsDir: 'static', // 放置静态资源
- transpileDependencies: true,
- lintOnSave: false,
- // serve: {
- devServer: {
- port: 4000,
- open: true,
- proxy: {
- '/api': {
- target: process.env.VUE_APP_BASE_URL,
- changeOrigin: true,
- pathRewrite: {
- //路径重写
- '^/api': '/'
- }
- }
- }
- },
- configureWebpack: {
- output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
- filename: `js/[name]-[hash].js?time=${time}`,
- chunkFilename: `js/[name]-[hash].js?time=${time}`,
- },
- }
- /*
-
- 接口请求 地址 需要以/api开头 才会反向代理到target源
- 路径重写: 定义/api 真实请求时这个路径携不携带
- 重要:真实请求地址是:target + 路径重写的值 + 请求path
- 假设路径重写被编程‘’ 则/api/a 真实请求地址是 url/a
- 注意:这里设置/api开头 则request.js中baseUrl应当设置为/api,否则反向代理并不成功
- */
- // }
- })
|