UNPKG

965 BJavaScriptView Raw
1const path = require('path')
2const chalk = require('chalk')
3
4module.exports = ({
5 config,
6 type,
7}) => {
8 let modified = false
9
10 if (typeof config === 'string') {
11 config = path.resolve(config)
12 process.env.WEBPACK_BUILD_CONFIG_PATHNAME = config
13 console.log(
14 chalk.green('√ ')
15 + chalk.yellowBright('[super/build] ')
16 + `set env ` + chalk.green('WEBPACK_BUILD_CONFIG_PATHNAME')
17 + `\n -> `
18 + config
19 )
20 modified = true
21 }
22
23 if (typeof type === 'string') {
24 process.env.SUPER_PROJECT_TYPE = type
25 console.log(
26 chalk.green('√ ')
27 + chalk.yellowBright('[super/build] ')
28 + `set env ` + chalk.green('SUPER_PROJECT_TYPE')
29 + `\n -> `
30 + type
31 )
32 modified = true
33 }
34
35 if (modified) console.log(' ')
36
37 return {
38 config, type
39 }
40}