forked from dod-ccpo/atat-web-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
113 lines (95 loc) · 2.76 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
const servicenowConfig = require('./servicenow.config');
const DEFAULTS = {
ASSET_SIZE_LIMIT: 10000
}
const CONFIG = {
...DEFAULTS,
...servicenowConfig
}
module.exports = {
transpileDependencies: [
'vuex-module-decorators'
],
// eslint-disable-next-line no-unused-vars
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
// config.entry = {
// [CONFIG.JS_API_PATH + 'app']: ['./src/main.ts'],
// }
config.optimization = {
splitChunks: {
cacheGroups: {
vendors: {
chunks: 'all',
minChunks: 1,
maxSize: 0,
name: 'vendor',
test: /([\\/]node_modules[\\/])|(assets\/)/,
priority: -10,
},
},
},
}
config.output.filename = 'js/[name]-[hash]-js'
config.output.chunkFilename = 'js/[name]-[chunkhash]-js'
}
},
chainWebpack: config => {
let BASE_API_URL = process.env.BASE_API_URL;
if (!BASE_API_URL) {
console.error("You must provide a value for property BASE_API_URL. Stopping.");
return process.exit(1);
}
BASE_API_URL += BASE_API_URL.endsWith("/") ? "api" : "/api";
let SNOWUSER = process.env.NODE_ENV === 'development' ? process.env.SNOWUSER :'';
let SNOWPASS = process.env.NODE_ENV === 'development' ? process.env.SNOWPASS : '';
config.plugin('define').tap((definitions) => {
let _base = definitions[0]["process.env"];
definitions[0]["process.env"] = {
..._base,
'VUE_APP_BASE_API_URL': JSON.stringify(BASE_API_URL),
'VUE_APP_SNOWUSER': JSON.stringify(SNOWUSER),
'VUE_APP_SNOWPASS': JSON.stringify(SNOWPASS),
};
return definitions;
});
if (process.env.NODE_ENV === 'production') {
config.module
.rule("images")
.use("url-loader")
.loader("url-loader")
.tap(options => Object.assign(options, {
limit: CONFIG.ASSET_SIZE_LIMIT,
fallback: {
...options.fallback,
options: {
name: 'img/[name]-[hash:6]-[ext]',
}
}
}));
config.module
.rule("svg")
.use("file-loader")
.loader("file-loader")
.tap(options => Object.assign(options, {
name: 'img/[name]-[hash:6]-[ext]',
}));
config.module
.rule("fonts")
.use("url-loader")
.loader("url-loader")
.tap(options => Object.assign(options, {
limit: CONFIG.ASSET_SIZE_LIMIT,
fallback: {
...options.fallback,
options: {
name: 'other_assets/[name]-[hash:6]-[ext]',
}
}
}));
}
},
css: {
extract: false,
},
}