Skip to content

Commit

Permalink
chore(webpack): resolve au run (without watch) error
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVinke committed Jul 24, 2017
1 parent e1f8b94 commit 7f5e84c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
15 changes: 12 additions & 3 deletions lib/resources/tasks/run-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import webpack from 'webpack';
import Server from 'webpack-dev-server';
import project from '../aurelia.json';
import {CLIOptions, reportWebpackReadiness} from 'aurelia-cli';
import build from './build';

function run(done) {
// https://webpack.github.io/docs/webpack-dev-server.html
Expand All @@ -21,7 +22,7 @@ function run(done) {
};

if (!CLIOptions.hasFlag('watch')) {
opts.watch = false;
opts.lazy = true;
}

if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
Expand All @@ -34,8 +35,16 @@ function run(done) {

server.listen(opts.port, opts.host, function(err) {
if (err) throw err;
reportWebpackReadiness(opts);
done();

if (opts.lazy) {
build(() => {
reportWebpackReadiness(opts);
done();
});
} else {
reportWebpackReadiness(opts);
done();
}
});
}

Expand Down
17 changes: 13 additions & 4 deletions lib/resources/tasks/run-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as webpack from 'webpack';
import * as Server from 'webpack-dev-server';
import * as project from '../aurelia.json';
import {CLIOptions, reportWebpackReadiness} from 'aurelia-cli';
import build from './build';

function run(done) {
// https://webpack.github.io/docs/webpack-dev-server.html
Expand All @@ -18,10 +19,10 @@ function run(done) {
stats: {
colors: require('supports-color')
}
};
} as any;

if (!CLIOptions.hasFlag('watch')) {
opts.watch = false;
opts.lazy = true;
}

if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
Expand All @@ -34,8 +35,16 @@ function run(done) {

server.listen(opts.port, opts.host, function(err) {
if (err) throw err;
reportWebpackReadiness(opts);
done();

if (opts.lazy) {
build(() => {
reportWebpackReadiness(opts);
done();
});
} else {
reportWebpackReadiness(opts);
done();
}
});
}

Expand Down

0 comments on commit 7f5e84c

Please sign in to comment.