-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
212 lines (204 loc) · 7.09 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
const path = require('path')
const debug = process.env.NODE_ENV !== 'production'
const configView = require("./static/mock/zbfx.json")
const configtest = require("./static/mock/test.json")
const PrefaceData = require("./static/mock/PrefaceData.json")
const Preface = require("./static/mock/Preface.json")
const tableData = require("./static/mock/tableData.json")
// const configtest = require("./static/mock/test.json")
const Risk = require("./static/profit/t.json") // 风险分析
const company1 = require("./static/mock/company.1.json") // 风险分析
const Configtest1 = require("./static/profit/test1.json") // 利润表
const Configtest2 = require("./static/profit/test2.json") // 利润表
const list = require("./static/profit/list.json") // 风险分析列表
// const Report_view = require("./static/profit/Report_view.json")
const operating = require("./static/profit/operating.json") // 操作按钮
const cross = require("./static/profit/cross.json") // 秋收
function resolve(dir) {
return path.join(__dirname, dir)
}
let proxyObj = { // 配置跨域
'/api': {
target: 'http://192.168.2.224:8005',
// target: 'http://192.168.1.118:8005',
// target: 'http://192.168.1.139:8005',
// target: 'http://192.168.1.139:8005',
ws: true,
changOrigin: true,
pathRewrite: {
'^/api': '/'
}
},
'/file': {
target: 'http://192.168.1.224:8002/api',
ws: true,
changOrigin: true,
pathRewrite: {
'^/file': '/'
}
},
'/cnbi': {
target: 'http://192.168.1.118:8081', //gjx
// target: 'http://192.168.1.118:8081', //gjx
// target: 'http://192.168.2.34:8081',
// target: 'http://192.168.1.138:8000',
// target: 'http://192.168.1.149:8000',
ws: true,
changOrigin: true,
pathRewrite: {
'^/cnbi': '/'
}
},
'/get': {
//target: 'http://192.168.2.2:8010',
target: 'http://192.168.1.118:8009',
ws: true,
changOrigin: true,
pathRewrite: {
'^/get': '/'
}
},
'/echart': {
target: 'http://www.echartsjs.com',
ws: true,
changOrigin: true,
pathRewrite: {
'^/echart': '/'
}
}
};
module.exports = {
// baseUrl: debug ? '/' : '/production-sub-path/',
baseUrl: debug ? '/' : '/jsnk', //attendance.. client
outputDir: 'dist', // 构建输出目录
assetsDir: 'assets', // 静态资源目录 (js, css, img, fonts)
lintOnSave: false, // 是否开启eslint保存检测,有效值:ture | false | 'error'
runtimeCompiler: true, // 运行时版本是否需要编译
transpileDependencies: [/\/node_modules\/resize-detector\//], // 默认babel-loader忽略mode_modules,这里可增加例外的依赖包名
productionSourceMap: false, // 是否在构建生产包时生成 sourceMap 文件,false将提高构建速度
// css相关配置
css: {
// 是否使用css分离插件 ExtractTextPlugin
extract: false,
// 开启 CSS source maps?
sourceMap: true,
// css预设器配置项
loaderOptions: {},
// 启用 CSS modules for all css / pre-processor files.
modules: false
},
// mode: 'production',
pages: {
index: {
// 页面的入口文件
// entry: 'src/views/message_page/main.js',
entry: 'src/views/layout/main.js',
// 页面的模板文件
template: 'public/index.html',
// build 生成的文件名称 例: dist/index.html
filename: 'index.html'
},
// template 默认会去找 public/subpage.html 页面,如果找不到会使用 public/index.html 文件
// 输出文件会默认的推断为 subpage.html
// black: 'src/views/layout/main.js',
// green: 'src/views/green/main.js',
// white: 'src/views/white/main.js',
},
configureWebpack: config => {
// webpack配置,值位对象时会合并配置,为方法时会改写配置
if (debug) {
// 开发环境配置
config.devtool = 'cheap-module-eval-source-map'
// 生产环境配置
proxy: proxyObj; // string | Object
} else {}
config.resolve = {
extensions: ['.js', '.vue', '.json', ".css"],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'@c': resolve('src/components'),
'@a': resolve('src/assets'), // 配置静态图片引入别名,引用图片时前面加~,在css中引入则加~
'@s': resolve('src/styles'),
'~api': resolve('src/api'),
'@v': resolve('src/views'),
"utils": resolve('src/utils'),
"@ms": resolve('src/views/message_page/styles'), // 消息页面的 样式
"@ma": resolve('src/views/message_page/assets'), // 消息页面的 静态资源
"@mc": resolve('src/views/message_page/components'), // 消息页面的 公用组件
'@mp': resolve('src/views/message_page/pages'), // 消息页面的 页面文件夹
'@mu': resolve('src/views/message_page/utils'), // 消息页面的 utils
'@m_api': resolve('src/views/message_page/api') // 消息页面的 样式
}
}
},
chainWebpack: config => { // webpack链接API,用于生成和修改webapck配置,https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
if (debug) {
// 本地开发配置
} else {
// 生产开发配置
}
},
parallel: require('os').cpus().length > 1, // 构建时开启多进程处理babel编译
pluginOptions: { // 第三方插件配置
},
pwa: { // 单页插件相关配置 https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
},
devServer: {
// index: 'black.html', //绿色启动页面
// index: 'green.html', //绿色启动页面
// index: 'white.html', //白色启动页面
open: false,
host: '0.0.0.0',
port: 8082,
https: false,
hotOnly: false,
// proxy: 'http://localhost:8081/api/', // 配置跨域处理,只有一个代理
proxy: proxyObj, // string | Object
// 自定义加载数据
before: app => {
app.get('/api/qwe', (req, res) => {
res.json(configView)
}),
app.get('/apis/PrefaceData', (req, res) => {
res.json(PrefaceData)
}),
app.get('/apis/Preface', (req, res) => {
res.json(Preface)
}),
app.get('/apis/tableData', (req, res) => {
res.json(tableData)
}),
app.get('/apis/test', (req, res) => {
res.json(configtest)
}),
app.get('/api/Risk', (req, res) => {
res.json(Risk)
}),
app.get('/api/company1', (req, res) => {
res.json(company1)
}),
app.get('/apis/Configtest1', (req, res) => {
res.json(Configtest1)
}),
app.get('/apis/Configtest2', (req, res) => {
res.json(Configtest2)
}),
app.get('/api/list', (req, res) => {
res.json(list)
}),
// app.get('/api/Report_view', (req, res) => {
// res.json(Report_view)
// }),
app.get('/api/operating', (req, res) => {
res.json(operating)
}),
app.get('/api/cross', (req, res) => {
res.json(cross)
})
},
// vue-cli 解决Invalid Host header,
// compress: true,
disableHostCheck: true, // That solved it
}
}