| Server IP : 46.62.235.243 / Your IP : 216.73.216.217 Web Server : Apache/2.4.58 (Ubuntu) System : Linux Linkabili3Dicembre 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/linkabili/node_modules/laravel-mix/src/webpackPlugins/ |
Upload File : |
let Log = require('../Log');
let collect = require('collect.js');
class CustomTasksPlugin {
/**
* Apply the plugin.
*
* @param {Object} compiler
*/
apply(compiler) {
compiler.plugin('done', stats => {
Mix.tasks.forEach(task => this.runTask(task, stats));
if (Mix.components.get('version')) {
this.applyVersioning();
}
if (Mix.inProduction()) {
this.minifyAssets();
}
if (Mix.isWatching()) {
Mix.tasks.forEach(task => task.watch(Mix.isPolling()));
}
Mix.manifest.refresh();
});
}
/**
* Execute the task.
*
* @param {Task} task
*/
runTask(task, stats) {
task.run();
task.assets.forEach(asset => {
Mix.manifest.add(asset.pathFromPublic());
// Update the Webpack assets list for better terminal output.
stats.compilation.assets[asset.pathFromPublic()] = {
size: () => asset.size(),
emitted: true
};
});
}
/**
* Minify the given asset file.
*/
minifyAssets() {
collect(Mix.tasks)
.where('constructor.name', '!==', 'VersionFilesTask')
.where('constructor.name', '!==', 'CopyFilesTask')
.each(({ assets }) =>
assets.forEach(asset => {
try {
asset.minify();
} catch (e) {
Log.error(
`Whoops! We had trouble minifying "${asset.relativePath()}". ` +
`Perhaps you need to use mix.babel() instead?`
);
throw e;
}
})
);
}
/**
* Version all files that are present in the manifest.
*/
applyVersioning() {
collect(Mix.manifest.get()).each((value, key) =>
Mix.manifest.hash(key)
);
}
}
module.exports = CustomTasksPlugin;