|
@ -26,6 +26,11 @@ const args = yargs |
|
|
default: [], |
|
|
default: [], |
|
|
global: true |
|
|
global: true |
|
|
}) |
|
|
}) |
|
|
|
|
|
.option('env', { |
|
|
|
|
|
description: 'The value for the environment variable, NODE_ENV', |
|
|
|
|
|
string: true, |
|
|
|
|
|
global: true |
|
|
|
|
|
}) |
|
|
.command('start', 'Build a project in development mode') |
|
|
.command('start', 'Build a project in development mode') |
|
|
.command('build', 'Compile the source directory to a bundled build') |
|
|
.command('build', 'Compile the source directory to a bundled build') |
|
|
.command('test [files..]', 'Run all suites from the test directory or provided files', { |
|
|
.command('test [files..]', 'Run all suites from the test directory or provided files', { |
|
@ -48,7 +53,6 @@ const args = yargs |
|
|
.argv; |
|
|
.argv; |
|
|
|
|
|
|
|
|
function run(command, args) { |
|
|
function run(command, args) { |
|
|
const environments = { build: 'production', start: 'development', test: 'test' }; |
|
|
|
|
|
const pkg = optional(join(process.cwd(), 'package.json')) || {}; |
|
|
const pkg = optional(join(process.cwd(), 'package.json')) || {}; |
|
|
const pkgMiddleware = pathOr([], ['neutrino', 'use'], pkg); |
|
|
const pkgMiddleware = pathOr([], ['neutrino', 'use'], pkg); |
|
|
const middleware = [...new Set(pkgMiddleware.concat(args.use))]; |
|
|
const middleware = [...new Set(pkgMiddleware.concat(args.use))]; |
|
@ -56,8 +60,6 @@ function run(command, args) { |
|
|
const config = pathOr({}, ['neutrino', 'config'], pkg); |
|
|
const config = pathOr({}, ['neutrino', 'config'], pkg); |
|
|
const api = new Neutrino(Object.assign(options, { config })); |
|
|
const api = new Neutrino(Object.assign(options, { config })); |
|
|
|
|
|
|
|
|
process.env.NODE_ENV = environments[command]; |
|
|
|
|
|
|
|
|
|
|
|
// Grab all middleware and merge them into a single webpack-chain config instance |
|
|
// Grab all middleware and merge them into a single webpack-chain config instance |
|
|
api.import(middleware); |
|
|
api.import(middleware); |
|
|
|
|
|
|
|
|