Skip to content

Commit e8e83a9

Browse files
authored
Allow non-production builds (#653)
* fix: `--production false` === `--no-production` * tie CSS extraction to `isWatch` bool
1 parent e621965 commit e8e83a9

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/commands/build.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { isDir, error } from '../util';
44
import asyncCommand from '../lib/async-command';
55
import runWebpack, { showStats, writeJsonStats } from '../lib/webpack/run-webpack';
66

7+
const toBool = val => val === void 0 || (val === 'false' ? false : val);
8+
79
export default asyncCommand({
810
command: 'build [src] [dest]',
911

@@ -60,6 +62,9 @@ export default asyncCommand({
6062
let cwd = resolve(argv.cwd);
6163
let modules = resolve(cwd, 'node_modules');
6264

65+
argv.prerender = toBool(argv.prerender);
66+
argv.production = toBool(argv.production);
67+
6368
if (!isDir(modules)) {
6469
return error('No `node_modules` found! Please run `npm install` before continuing.', 1);
6570
}

src/lib/webpack/run-webpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { error, isDir, warn } from '../../util';
1313

1414
export default function (watch=false, env, onprogress) {
1515
env.isProd = env.production; // shorthand
16+
env.isWatch = !!watch; // use HMR?
1617
env.cwd = resolve(env.cwd || process.cwd());
1718

1819
// env.src='src' via `build` default

src/lib/webpack/webpack-base-config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function resolveDep(dep, cwd) {
2525
}
2626

2727
export default function (env) {
28-
const { cwd, isProd, src, source } = env;
28+
const { cwd, isProd, isWatch, src, source } = env;
2929

3030
// Apply base-level `env` values
3131
env.dest = resolve(cwd, env.dest || 'build');
@@ -210,7 +210,7 @@ export default function (env) {
210210
// Extract CSS
211211
new ExtractTextPlugin({
212212
filename: isProd ? 'style.[contenthash:5].css' : 'style.css',
213-
disable: !isProd,
213+
disable: isWatch,
214214
allChunks: true
215215
}),
216216
new webpack.optimize.CommonsChunkPlugin({
@@ -239,7 +239,7 @@ export default function (env) {
239239
})
240240
] : []),
241241

242-
devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
242+
devtool: isWatch ? 'cheap-module-eval-source-map' : 'source-map',
243243

244244
node: {
245245
console: false,

0 commit comments

Comments
 (0)