Skip to content

Instantly share code, notes, and snippets.

@orionstar
Created March 16, 2022 04:10
Show Gist options
  • Save orionstar/7588719d8f4e7481077f209fe1ff2df4 to your computer and use it in GitHub Desktop.
Save orionstar/7588719d8f4e7481077f209fe1ff2df4 to your computer and use it in GitHub Desktop.
Laravel Mix - Copy outside the public path & use version() with the other files
const mix = require('laravel-mix')
const CopyWebpackPlugin = require('copy-webpack-plugin')
/**
* Mix doesn't support copy content outside the public path AND simultaneously using version()
*/
class CopyOutside {
tasks = [];
name() {
return 'copyOutside';
}
dependencies() {
return [
'copy-webpack-plugin'
];
}
register(from, to) {
this.tasks.push({
from: from,
to: to
});
}
webpackPlugins() {
return [new CopyWebpackPlugin({
patterns: this.tasks,
})];
}
}
mix.extend('copyOutside', new CopyOutside());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment