Skip to content

Commit

Permalink
Improve: Update build command to set NODE_ENV based on args
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Feb 20, 2024
1 parent e19746b commit 8c0783e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/techor/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ export default (program: Command) => program.command('build [entryPaths...]')
try {
const useConfig = exploreConfig('techor.config.*') as Config
const config = extend(defaultConfig, useConfig, { build: commandBuildOptions }) as Config

if (this.args.includes('dev')) {
process.env.NODE_ENV = 'development'
config.build.watch = true
} else {
process.env.NODE_ENV = 'production'
}
if (file !== undefined) config.build.output.file = file
if (external !== undefined) config.build.external = external

Expand All @@ -82,9 +87,6 @@ export default (program: Command) => program.command('build [entryPaths...]')
const buildMap = new Map<RollupInputOptions['input'], BuildOptions>()

if (config.build.declare === undefined && types) config.build.declare = true
if (this.args[0] === 'dev') {
config.build.watch = true
}

if (Array.isArray(config.build.external)) {
if (dependencies) config.build.external.push(...Object.keys(dependencies))
Expand Down

0 comments on commit 8c0783e

Please sign in to comment.