-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
vue.config.js
206 lines (176 loc) · 6.92 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
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const result = {
publicPath: '/',
css: {
sourceMap: true,
loaderOptions: {
sass: {
additionalData: `
@import '@/assets/sass/variables.scss';
@import '@/assets/sass/mixins.scss';
`,
},
},
},
productionSourceMap: true,
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;
});
// also handle avif format
config.module.rule('images').test(/\.(png|jpe?g|gif|webp|avif)(\?.*)?$/);
},
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: [],
},
};
/* Please note 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
bingApiKey: undefined,
ordnanceSurveyApiKey: 'eUaDulZ6AqXJo7iyoP2lRsgUjKfZWA71',
isBackendSelectable: true,
addthisPublicId: 'ra-58abf6b4f3a680cb',
googleAnalyticsKey: 'UA-2814179-1',
urlsConfigurations: {
demo: {
name: 'demo',
api: 'https://api.demov6.camptocamp.org',
media: 'https://sos-ch-dk-2.exo.io/c2corg-demov6-active',
imageBackend: 'https://images.demov6.camptocamp.org',
tracking: 'https://tracking.demov6.camptocamp.org',
miniatures: 'https://sos-ch-dk-2.exo.io/c2corg-demov6-tracking',
forum: 'https://forum.demov6.camptocamp.org',
recaptchaKey: '6LfWUwoUAAAAAAxud1qqok6wOJJlCUsYXxHizRhc',
modernThumbnailsTimestamp: 0,
modernThumbnailsId: 0,
stravaConnectAuthUrl: 'https://www.strava.com/oauth/authorize',
stravaClientId: '99246',
decathlonConnectAuthUrl: 'https://api-global.decathlon.net/connect/oauth/authorize',
decathlonClientId: 'b708af3b-fd46-41ab-af73-5176a0a56f92',
suuntoConnectAuthUrl: 'https://cloudapi-oauth.suunto.com/oauth/authorize',
suuntoClientId: '2928e564-85eb-4aef-92fb-2a0259589c9c',
polarConnectAuthUrl: 'https://flow.polar.com/oauth2/authorization',
polarClientId: '65d10592-5abf-41d6-a5ce-b16a28174849',
corosConnectAuthUrl: 'https://opentest.coros.com/oauth2/authorize',
corosClientId: 'f263ed9257c74e808befaf548a27852c',
},
prod: {
name: 'prod',
api: 'https://api.camptocamp.org',
media: 'https://media.camptocamp.org/c2corg-active',
imageBackend: 'https://images.camptocamp.org',
tracking: 'https://tracking.camptocamp.org',
miniatures: 'https://media.camptocamp.org/c2corg-tracking',
forum: 'https://forum.camptocamp.org',
recaptchaKey: '6Lc9Cw4UAAAAAIKnlar0AOsGX_P5S-bk9u8viuo2',
modernThumbnailsTimestamp: 0,
modernThumbnailsId: 0,
stravaConnectAuthUrl: 'https://www.strava.com/oauth/authorize',
stravaClientId: '63968',
decathlonConnectAuthUrl: 'https://api-global.decathlon.net/connect/oauth/authorize',
decathlonClientId: 'b708af3b-fd46-41ab-af73-5176a0a56f92',
suuntoConnectAuthUrl: 'https://cloudapi-oauth.suunto.com/oauth/authorize',
suuntoClientId: '2928e564-85eb-4aef-92fb-2a0259589c9c',
polarConnectAuthUrl: 'https://flow.polar.com/oauth2/authorization',
polarClientId: '5a9f9ddd-fc15-48d2-bc56-86b43d491cc9',
corosConnectAuthUrl: 'https://open.coros.com/oauth2/authorize',
corosClientId: 'f263ed9257c74e808befaf548a27852c',
},
},
};
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 developers:
config.urlsConfigurations.localhost = {
name: 'localhost',
api: 'http://localhost:6543',
media: 'https://sos-ch-dk-2.exo.io/c2corg-demov6-active',
imageBackend: 'https://images.demov6.camptocamp.org',
forum: 'https://forum.demov6.camptocamp.org',
modernThumbnailsTimestamp: 0,
modernThumbnailsId: 0,
};
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.bingApiKey = 'AudizIfCd3NAdt91ubJMGkMI-swfHxe1R-_U7KiLxCHqepDy70txQ-_-89_eevxc';
config.isBackendSelectable = false; // explicit 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;