forked from radiantearth/stac-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
82 lines (75 loc) · 2.31 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
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"))
.option(
Object.fromEntries(
optionsForType("object").map((k) => [k, { coerce: JSON.parse }])
)
)
.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;
args[0].url = mergedConfig.catalogUrl;
return args;
});
const svgRule = webpackConfig.module.rule('svg');
svgRule.uses.clear();
svgRule.delete('type');
svgRule.delete('generator');
svgRule
.use('vue-loader')
.loader('vue-loader')
.end()
.use("./vue-svg-loader")
.loader("./vue-svg-loader");
},
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;