Skip to content

Commit

Permalink
Catch not found errors in combine/scripts/styles
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Oct 10, 2021
1 parent c539c01 commit be946e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/webpackPlugins/CustomTasksPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@ class CustomTasksPlugin {
* @param {import("webpack").Compiler} compiler
*/
apply(compiler) {
compiler.hooks.done.tapAsync(this.constructor.name, (stats, callback) => {
this.runTasks(stats).then(async () => {
if (this.mix.components.get('version') && !this.mix.isUsing('hmr')) {
this.applyVersioning();
}

if (this.mix.inProduction()) {
await this.minifyAssets();
}

if (this.mix.isWatching()) {
this.mix.tasks.forEach(task => task.watch(this.mix.isPolling()));
}

this.mix.manifest.refresh();
callback();
});
compiler.hooks.done.tapPromise(this.constructor.name, async stats => {
await this.runTasks(stats);

if (this.mix.components.get('version') && !this.mix.isUsing('hmr')) {
this.applyVersioning();
}

if (this.mix.inProduction()) {
await this.minifyAssets();
}

if (this.mix.isWatching()) {
this.mix.tasks.forEach(task => task.watch(this.mix.isPolling()));
}

this.mix.manifest.refresh();
});
}

Expand Down
9 changes: 9 additions & 0 deletions test/features/combine.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,12 @@ test('it can concat files produced by the build', async t => {
t
);
});

test('combine with missing files throws an error', async t => {
mix.combine(
[`test/fixtures/app/src/css/i-do-not-exist.css`],
`test/fixtures/app/dist/all.css`
);

await t.throwsAsync(() => webpack.compile(), { code: 'ENOENT' });
});

0 comments on commit be946e7

Please sign in to comment.