Skip to content

Commit bb7cd85

Browse files
committed
Merge branch 'master' of github.com:shama/webpack-stream
2 parents 141e063 + 3287835 commit bb7cd85

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ module.exports = function (options, wp, done) {
3838
const isInWatchMode = !!options.watch;
3939
delete options.watch;
4040

41+
if (typeof config === 'string') {
42+
config = require(config);
43+
}
44+
4145
// Webpack 4 doesn't support the `quiet` attribute, however supports
4246
// setting `stats` to a string within an array of configurations
4347
// (errors-only|minimal|none|normal|verbose) or an object with an absurd
@@ -237,6 +241,19 @@ module.exports = function (options, wp, done) {
237241
} else {
238242
handleCompiler(compiler);
239243
}
244+
245+
if (options.watch && !isSilent) {
246+
const watchRunPlugin = compiler.hooks
247+
// Webpack 4
248+
? callback => compiler.hooks.watchRun.tapAsync('WebpackInfo', callback)
249+
// Webpack 2/3
250+
: callback => compiler.plugin('watch-run', callback);
251+
252+
watchRunPlugin((compilation, callback) => {
253+
fancyLog('webpack compilation starting...');
254+
callback();
255+
});
256+
}
240257
});
241258

242259
// If entry point manually specified, trigger that

test/fixtures/webpack.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Test config file for 'option file path' test.
2+
const config = {
3+
input: './entry.js'
4+
// input: './nope.js'
5+
};
6+
7+
module.exports = config;

test/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ test('no options', function (t) {
159159
stream.end();
160160
});
161161

162+
test('config file path with webpack-stream options', function (t) {
163+
t.plan(1);
164+
var stream = webpack({
165+
quiet: true,
166+
config: path.join(base, 'webpack.config.js')
167+
});
168+
stream.on('end', function () {
169+
t.ok(true, 'config successfully loaded from file, with webpack-stream options');
170+
});
171+
stream.end();
172+
});
173+
162174
test('error formatting', function (t) {
163175
t.plan(2);
164176
// TODO: Fix this to test to rely less on large string outputs as those can change

0 commit comments

Comments
 (0)