webpack-shell-plugin icon indicating copy to clipboard operation
webpack-shell-plugin copied to clipboard

Add onBeforeBuild

Open antonioribeiro opened this issue 8 years ago • 0 comments

Implementing webpack's invalid.

I needed this because I'm running an external script, to compile some files using PHP, and generating a .js file which should be then processed by webpack. Using onBuildStart did not fired it the way I thought it would, before webpack start to build things, and onBuildExit, saves the file after everything is done, firing a new webpack watch event, which results in a loop. The real problem was that, even when I had it updated at some point (yes it kind of worked without this), it was too late for LiveReload to catch the update files.

This is the use case:

const LiveReloadPlugin = require('webpack-livereload-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

mix.webpackConfig({
    plugins: [
        new LiveReloadPlugin(),

        new CopyWebpackPlugin([
            { from: 'resources/lang', to: '/tmp/resources/lang' },
        ], {
            copyUnmodified: true
        }),

        new WebpackShellPlugin({
            onBeforeBuild:['php artisan app:build-localization-json'],
        }),
    ]
});

CopyWebpackPlugin is responsible for watching those external files and triggering the change event during watch.

antonioribeiro avatar Jul 17 '17 21:07 antonioribeiro