-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvue.config.js
162 lines (159 loc) · 6.65 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// let url = global.setting && global.setting.baseUrl;
// let url = 'http://localhost:3300/';
let env = process.env.NODE_ENV;
const path = require('path')
console.log('启动环境:', env);
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
runtimeCompiler: true,
/** 区分打包环境与开发环境
* process.env.NODE_ENV==='production' (打包环境)
* process.env.NODE_ENV==='development' (开发环境)
* baseUrl: process.env.NODE_ENV==='production'?"https://cdn.didabisai.com/front/":'front/',
*/
// 项目部署的基础路径
// 我们默认假设你的应用将会部署在域名的根部,
// 例如 https://www.my-app.com/
// 如果你的应用部署在一个子路径下,那么你需要在这里
// 指定子路径。比如将你的应用部署在
// https://www.foobar.com/my-app/
// 那么将这个值改为 '/my-app/'
// baseUrl: "/",
// 构建好的文件输出到哪里
outputDir: "dist",
// where to put static assets (js/css/img/font/...)
// 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
assetsDir: "",
// 是否在保存时使用‘eslint-loader’进行检查
// 有效值: true | false | 'error',当设置为‘error’时,检查出的错误会触发编译失败
lintOnSave: false,
// 使用带有浏览器内编译器的完整构建版本 // https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only
// runtimeCompiler: false,
// babel-loader默认会跳过`node_modules`依赖. // 通过这个选项可以显示转译一个依赖
// transpileDependencies: [
// /* string or regex */
// ],
// 是否为生产环境构建生成sourceMap?
productionSourceMap: false,
// 调整内部的webpack配置. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
// configureWebpack: () => {
// },
// parallel: require("os").cpus().length > 1,
// PWA 插件相关配置 // see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
// pwa: {},
// configure webpack-dev-server behavior
chainWebpack: (config) => {
config.resolve.alias
.set('@', resolve('src'))
.set('@assets', resolve('src/assets'))
.set('@comp', resolve('src/components'))
.set('@public', resolve('public'))
},
css: {
// 将组件内部的css提取到一个单独的css文件(只用在生产环境)
// 也可以是传递给 extract-text-webpack-plugin 的选项对象
// extract: true,
// 允许生成 CSS source maps?
sourceMap: false,
loaderOptions: {
less: {
//If you are using less-loader@5 please spread the lessOptions to options directly
javascriptEnabled: true,
// modifyVars: {
// /* less 变量覆盖,用于自定义 ant design 主题 */
// 'primary-color': '#2daef6',
// 'link-color': '#2daef6',
// 'border-radius-base': '4px',
// },
}
}
},
pages: {
index: {
// page 的入口
entry: 'src/main.js',
// 模板来源
template: 'public/index.html',
// 在 dist/index.html 的输出
filename: 'index.html',
// 当使用 title 选项时,
// template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: '管理系统',
// 在这个页面中包含的块,默认情况下会包含
// 提取出来的通用 chunk 和 vendor chunk。
chunks: ['chunk-vendors', 'chunk-common', 'index']
}
},
devServer: {
// 让浏览器 overlay 同时显示警告和错误
overlay: {
warnings: false,
errors: false
},
// open: process.platform === "darwin",
disableHostCheck: false,
host: "0.0.0.0",
port: 8080,
https: false,
hotOnly: false, // See https://github.com/vuejs/vue-cli/blob/dev/docs/cli-service.md#configuring-proxy
proxy: {
'/videoability': {
target: 'http://localhost:9999/', // 接口的域名
// secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
// pathRewrite: {
// 把 /api 开头的路径替换为 ''
// '^/api': ''
// }
},
'/ws': {
target: 'http://localhost:9093/', // 接口的域名
ws: true,
// secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
// pathRewrite: {
// 把 /api 开头的路径替换为 ''
// '^/api': ''
// }
},
'/api': {
target: 'http://localhost:9093/', // 接口的域名
// secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
// pathRewrite: {
// 把 /api 开头的路径替换为 ''
// '^/api': ''
// }
},
'/open-api': {
target: 'http://localhost:80/', // 接口的域名
// secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
pathRewrite: {
// 把 /open-api 开头的路径替换为 '/open'
'^/open-api': '/open'
}
},
'/file': {
target: 'http://localhost:9093/', // 接口的域名
// secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
}
},
// string | Object
// before: app => {}
},
// 第三方插件配置
pluginOptions: {
// "style-resources-loader": {
// preProcessor: "less",
// patterns: [
// //这个是加上自己的路径,
// //注意:试过不能使用别名路径
// path.resolve(__dirname, "public/color.less")
// ]
// }
},
};