Skip to content

Commit

Permalink
Better error handling for plugin-bundle-webpack (#64)
Browse files Browse the repository at this point in the history
* added @snowpack/plugin-bundle-webpack

* File loader test pattern is now .*

* Excluded other patterns in file-loader, otherwise breaks

* Fix asset pattern

* Added extendConfig to plugin-bundle-webpack

* More config options for plugin-bundle-webpack.js

* Replaced optional chaining for earlier node versions

* Better error handling
  • Loading branch information
lajoiemedia authored and drwpow committed Jul 27, 2020
1 parent 806303b commit e61799c
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ async function compilePromise(webpackConfig) {
const compiler = webpack(webpackConfig);
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
if (stats.hasErrors()) {
reject(err);
if (stats.hasErrors() || err) {
const info = stats.toJson();
reject({ err, infoErrors: info.errors, infoWarnings: info.warning });
}
resolve(stats);
});
Expand Down Expand Up @@ -162,8 +163,13 @@ module.exports = function plugin(config, args) {
filename: jsOutputPattern,
},
})
).catch((err) => {
console.log(err);
).catch(({ err, infoErrors }) => {
if (err) {
console.error(err.stack || err);
}
if (infoErrors && infoErrors.length > 0) {
console.error(infoErrors.join("\n-----\n"));
}
});

if (!args.skipFallbackOutput) {
Expand Down

0 comments on commit e61799c

Please sign in to comment.