| 12345678910111213141516171819202122232425262728293031323334 |
- const { defineConfig } = require('@vue/cli-service')
- module.exports = defineConfig({
- transpileDependencies: true,
- // 配置开发服务器(包括代理)
- publicPath: "/",
- // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
- outputDir: 'dist',
- // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
- assetsDir: 'static',
- // 是否开启eslint保存检测,有效值:ture | false | 'error'
- lintOnSave: true, // 保存时触发ESLint检查,有错误仅警告,不阻断编译
- // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
- productionSourceMap: false,
- devServer: {
- // 开启代理
- proxy: {
- // 1. 匹配以 /api 开头的请求(自定义前缀)
- '/api': {
- // 目标后端接口地址(替换成你的实际接口地址)
- target: 'http://192.168.124.67:30000/',
- // 开启跨域(必须设置,否则代理无效)
- changeOrigin: true,
- // 路径重写:去掉请求路径中的 /api 前缀(根据后端接口是否需要前缀决定)
- // 例如:前端请求 /api/user → 实际转发到 http://localhost:8080/user
- pathRewrite: {
- '^/api': ''
- },
- // 可选:如果后端是 https 接口,需要设置为 true
- // secure: false
- },
- }
- }
- })
|