forked from WeBankFinTech/DataSphereStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
106 lines (102 loc) · 2.98 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
/*
* Copyright 2019 WeBank
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// vue.config.js
let CopyWebpackPlugin = require('copy-webpack-plugin')
let FileManagerPlugin = require('filemanager-webpack-plugin');
let MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
let path = require('path')
let fs = require('fs');
const getVersion = () => {
const pkgPath = path.join(__dirname, './package.json');
let pkg = fs.readFileSync(pkgPath);
pkg = JSON.parse(pkg);
return pkg.version;
}
const host = "0.0.0.0";
const port = "9001";
module.exports = {
publicPath: './',
outputDir: 'dist/dist',
devServer: {
port: 8080,
open: true,
disableHostCheck: true,
overlay: {
warnings: false,
errors: true
},
proxy: { //代理转发
'^/api/rest_j/v1': {
target: `http://${host}:${port}`, //后端服务地址
ws: true,
changeOrigin: true,
pathRewrite: {
'^/api/rest_j/v1': '/api/rest_j/v1'
}
},
'^/ws/api': { //websocket
target: `ws://${host}:${port}`,
ws: true,
secure: false,
},
}
// after: require('./mock/mock-server.js')
},
chainWebpack: (config) => {
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'sandbox') {
config.plugin('compress').use(FileManagerPlugin, [{
onEnd: {
copy: [
{ source: 'node_modules/monaco-editor/dev/vs', destination: `./dist/dist/static/vs` },
{ source: './config.sh', destination: `./dist/conf` },
{ source: './install.sh', destination: `./dist/bin` }
],
// 先删除根目录下的zip包
delete: [`./wedatasphere-DataSphereStudio-${getVersion()}-dist.zip`],
// 将dist文件夹下的文件进行打包
archive: [
{ source: './dist', destination: `./wedatasphere-DataSphereStudio-${getVersion()}-dist.zip` },
]
},
}])
}
},
configureWebpack: {
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve(__dirname, './src'),
'@js': path.resolve(__dirname, './src/js'),
'@assets': path.resolve(__dirname, './src/assets')
}
},
plugins: [
new CopyWebpackPlugin([{
from: 'node_modules/monaco-editor/dev/vs',
to: 'static/vs',
}]),
new MonacoWebpackPlugin({}),
]
},
// 选项...
pluginOptions: {
mock: {
entry: 'mock.js',
power: false
}
}
}