forked from c2corg/c2c_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
165 lines (138 loc) · 5.12 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
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const result = {
publicPath: '/',
chainWebpack(config) {
// remove prefetch plugin, in order to prevent loading of translations
// https://github.com/vuejs/vue-cli/issues/979#issuecomment-373310338
config.plugins.delete('prefetch');
// preserveWhitespace option was set to false by default in vue-cli v4
// https://cli.vuejs.org/migrating-from-v3/#vue-cli-service
// cutomize options
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap((options) => {
// modify the options...
delete options.compilerOptions.preserveWhitespace;
options.compilerOptions.whitespace = 'condensed';
return options;
});
},
configureWebpack: {
performance: {
hints: 'error',
// TODO sizes checks are on compiled files, instead of GZIP sizes
// PR is ready on Webpack side :
// https://github.com/webpack/webpack/pull/7910
//
// And here is THE option :
//
// compress:true,
//
// But they did not merge it....
// waiting this, we increase the limit by 4
// approx the decrease Gzip ratio on a .js minified files
maxAssetSize: 300000 * 4,
// and we allow a entry point of 450 kb gzipped
maxEntrypointSize: 500000 * 4,
assetFilter(assetFilename) {
if (/\.map$/.test(assetFilename)) {
return false;
}
if (/\.pdf$/.test(assetFilename)) {
return false;
}
return true;
},
},
plugins: [
// moment, by default load all locales
// this will skip all of it, and a fixed list is setted in @/tools/vue-moment',
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
],
},
};
/* Please not that all key present in this file are public keys
* They don't need to be hidden.
* If you need to use a private key, please do NOT add it here
*/
const config = {
routerMode: 'history', // for pretty urls
ignApiKey: undefined,
bingApiKey: undefined,
isProduction: false,
addthisPublicId: 'ra-58abf6b4f3a680cb',
googleAnalyticsKey: 'UA-2814179-1',
urlsConfigurations: {
demo: {
name: 'demo',
api: 'https://api.demov6.camptocamp.org',
media: 'https://sos.exo.io/c2corg-demov6-active',
imageBackend: 'https://images.demov6.camptocamp.org',
forum: 'https://forum.demov6.camptocamp.org',
recaptchaKey: '6LfWUwoUAAAAAAxud1qqok6wOJJlCUsYXxHizRhc',
},
prod: {
name: 'prod',
api: 'https://api.camptocamp.org',
media: 'https://media.camptocamp.org/c2corg_active',
imageBackend: 'https://images.camptocamp.org',
forum: 'https://forum.camptocamp.org',
recaptchaKey: '6Lc9Cw4UAAAAAIKnlar0AOsGX_P5S-bk9u8viuo2',
},
},
};
config.urls = config.urlsConfigurations.prod; // default : prod
const bundleAnalyzerConfig = {
analyzerMode: 'disabled',
openAnalyzer: false,
};
if (process.env.BUILD_ENV === 'local' || process.env.BUILD_ENV === undefined) {
// add an url conf for local API devloppers :
config.urlsConfigurations.localhost = {
name: 'localhost',
api: 'http://localhost:6543',
media: 'https://sos.exo.io/c2corg-demov6-active',
imageBackend: 'https://images.demov6.camptocamp.org',
forum: 'https://forum.demov6.camptocamp.org',
};
config.ignApiKey = 'hzuh5yjuto8lqbqs2njo0che'; // Key valid for localhost (Expires 08/11/2019)
config.bingApiKey = 'ApgmUK6zfKqlvU9kNDbXeLFL2KvhC0BF3Jy-nUbcnkFJK_Y7UgMCyRq1NTu_ptyj';
// dev bundles are huge, no check
result.configureWebpack.performance.hints = false;
// add map for debbuging tools
result.configureWebpack.devtool = 'source-map';
} else if (process.env.BUILD_ENV === 'github') {
// github pages does not support server redirection, can't use pretty urls
config.routerMode = undefined;
// github pages url is postfixed
// and we will deploy a build on
// https://c2corg.github.io/c2c_ui/<branch-name>/
config.branchName = process.env.GITHUB_PAGES_BRANCH;
result.publicPath = `/c2c_ui/${config.branchName}/`;
// set a warning if bundle size is too big
result.configureWebpack.performance.hints = 'warning';
// generate a report on bundle size
bundleAnalyzerConfig.analyzerMode = 'static';
bundleAnalyzerConfig.reportFilename = 'bundle-analyzis.html';
bundleAnalyzerConfig.defaultSizes = 'gzip';
} else if (process.env.BUILD_ENV === 'camptocamp') {
config.urls = config.urlsConfigurations.prod;
config.ignApiKey = 'iq1rkryayi4z074da39pbg6s';
config.bingApiKey = 'AudizIfCd3NAdt91ubJMGkMI-swfHxe1R-_U7KiLxCHqepDy70txQ-_-89_eevxc';
config.isProduction = true; // explicit prod flag
// set a warning if bundle size is too big
result.configureWebpack.performance.hints = 'warning';
} else {
throw new Error('Unknown BUILD_ENV');
}
config.publicPath = result.publicPath;
result.configureWebpack.plugins.push(new BundleAnalyzerPlugin(bundleAnalyzerConfig));
result.configureWebpack.plugins.push(
new webpack.DefinePlugin({
CAMPTOCAMP_CONFIG: JSON.stringify(config),
})
);
module.exports = result;