1 | function buildConfig() {
|
2 | if (process.env.WEB) {
|
3 | return process.env.CONFIG
|
4 | } else {
|
5 | const { cosmiconfigSync } = require('cosmiconfig'),
|
6 | merge = require('lodash').merge,
|
7 | path = require('path'),
|
8 | pkgDir = require('pkg-dir'),
|
9 | rootDir = pkgDir.sync(process.cwd()),
|
10 | result = cosmiconfigSync(process.env.CONFIG_KEY || 'site').search(rootDir)
|
11 |
|
12 | return merge(
|
13 | {
|
14 | rootDir,
|
15 | srcDir: path.resolve(rootDir + '/src'),
|
16 | prePackDir: path.resolve(rootDir + '/prepack'),
|
17 | destDir: path.resolve(rootDir + '/dist'),
|
18 | },
|
19 | result?.config?.default || result?.config,
|
20 | )
|
21 | }
|
22 | }
|
23 |
|
24 | export default buildConfig()
|