forked from radiantearth/stac-browser
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vue.config.js
64 lines (59 loc) · 1.87 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
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const path = require('path');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const { properties } = require('./config.schema.json');
const pkgFile = require('./package.json');
const optionsForType = (type) => Object.entries(properties)
.filter(([_, schema]) => Array.isArray(schema.type) && schema.type.includes(type))
.map(([key]) => key);
const argv = yargs(hideBin(process.argv))
.parserConfiguration({'camel-case-expansion': false})
.env('SB')
.boolean(optionsForType("boolean"))
.number(optionsForType("number").concat(optionsForType("integer")))
.array(optionsForType("array"))
.argv;
// Clean-up arguments
delete argv._;
delete argv.$0;
const configFile = path.resolve(argv.CONFIG ? argv.CONFIG : './config.js');
const configFromFile = require(configFile);
const mergedConfig = Object.assign(configFromFile, argv);
const vueConfig = {
lintOnSave: process.env.NODE_ENV !== 'production',
productionSourceMap: !mergedConfig.noSourceMaps,
publicPath: mergedConfig.pathPrefix,
chainWebpack: webpackConfig => {
webpackConfig.plugin('define').tap(args => {
args[0].STAC_BROWSER_VERSION = JSON.stringify(pkgFile.version);
args[0].CONFIG_PATH = JSON.stringify(configFile);
args[0].CONFIG_CLI = JSON.stringify(argv);
return args;
});
webpackConfig.plugin('html').tap(args => {
args[0].title = mergedConfig.catalogTitle;
return args;
});
},
configureWebpack: {
resolve: {
fallback: {
'fs/promises': false
}
},
plugins: [
new NodePolyfillPlugin({
includeAliases: ['Buffer', 'path']
})
]
},
pluginOptions: {
i18n: {
locale: mergedConfig.locale,
fallbackLocale: mergedConfig.fallbackLocale,
enableInSFC: false
}
}
};
module.exports = vueConfig;