forked from rancher/opni-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
48 lines (36 loc) · 1.32 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
const config = require('@rancher/shell/vue.config');
const webpack = require('webpack');
const isStandalone = process.env.IS_STANDALONE === 'true';
let opniApi = process.env.OPNI_API || 'http://localhost:8888';
if (opniApi && !opniApi.startsWith('http')) {
opniApi = `http://${ opniApi }`;
}
if (opniApi) {
console.log(`OPNI API: ${ opniApi }`); // eslint-disable-line no-console
}
console.log(`IS STANDALONE`, isStandalone); // eslint-disable-line no-console
const baseConfig = config(__dirname, {
excludes: [],
// excludes: ['fleet', 'example']
});
const baseConfigureWebpack = baseConfig.configureWebpack;
baseConfig.devServer.proxy = {
'/opni-api': {
secure: false,
target: opniApi,
pathRewrite: { '^/opni-api': '' }
},
};
baseConfig.configureWebpack = (config) => {
config.plugins.push(new webpack.DefinePlugin({ 'process.env.isStandalone': JSON.stringify(isStandalone) }));
baseConfigureWebpack(config);
};
// Makes the public path relative so that the <base> element will affect the assets.
if (!isStandalone) {
baseConfig.publicPath = './';
}
// We need to add a custom script to the index in order to change how assets for the opni backendso we have to override the index.html
if (isStandalone) {
baseConfig.pages.index.template = './pkg/opni/index.html';
}
module.exports = baseConfig;