Skip to content

Commit

Permalink
Merge branch 'master' of github.com:shama/webpack-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
shama committed Aug 31, 2021
2 parents 141e063 + 3287835 commit bb7cd85
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ module.exports = function (options, wp, done) {
const isInWatchMode = !!options.watch;
delete options.watch;

if (typeof config === 'string') {
config = require(config);
}

// Webpack 4 doesn't support the `quiet` attribute, however supports
// setting `stats` to a string within an array of configurations
// (errors-only|minimal|none|normal|verbose) or an object with an absurd
Expand Down Expand Up @@ -237,6 +241,19 @@ module.exports = function (options, wp, done) {
} else {
handleCompiler(compiler);
}

if (options.watch && !isSilent) {
const watchRunPlugin = compiler.hooks
// Webpack 4
? callback => compiler.hooks.watchRun.tapAsync('WebpackInfo', callback)
// Webpack 2/3
: callback => compiler.plugin('watch-run', callback);

watchRunPlugin((compilation, callback) => {
fancyLog('webpack compilation starting...');
callback();
});
}
});

// If entry point manually specified, trigger that
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Test config file for 'option file path' test.
const config = {
input: './entry.js'
// input: './nope.js'
};

module.exports = config;
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ test('no options', function (t) {
stream.end();
});

test('config file path with webpack-stream options', function (t) {
t.plan(1);
var stream = webpack({
quiet: true,
config: path.join(base, 'webpack.config.js')
});
stream.on('end', function () {
t.ok(true, 'config successfully loaded from file, with webpack-stream options');
});
stream.end();
});

test('error formatting', function (t) {
t.plan(2);
// TODO: Fix this to test to rely less on large string outputs as those can change
Expand Down

0 comments on commit bb7cd85

Please sign in to comment.