Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack copy-webpack-plugin Runs Too Early

Tags:

webpack

I have a wepback.config.js file with the following plugin structure:

 /**************************************************
 Plugins imported:
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
    const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
    const CopyWebpackPlugin = require('copy-webpack-plugin');
    *********************************************************/

plugins: [
        new HtmlWebpackPlugin({
          inlineSource: '(main.bundle.js)',
          template: './web/leafletReact.html',
          inject: 'body'
        }),
        new webpack.optimize.UglifyJsPlugin({

          // Eliminate comments
             comments: false,

         // Compression specific options
            compress: {
              // remove warnings
                 warnings: false,

              // Drop console statements
                 drop_console: true
            },
         }),
        new HtmlWebpackInlineSourcePlugin(),
        new CopyWebpackPlugin([
                {
                    from: path.join(__dirname, '/build/*.html'),
                    to: path.join(__dirname, '/assets/dist'),
                    toType: 'dir',
                    flatten: true
                }
            ])
    ]

Even though CopyWebpackPlugin is listed last, it runs prior to the completion of HtmlWebpackInlineSourcePlugin . Is there a way to force CopyWebpackPlugin to wait until all the other plugins are finished?

like image 274
reggie3 Avatar asked Nov 08 '22 08:11

reggie3


1 Answers

For anyone having this issue please use FileManagerWebpackPlugin. Since copy-webpack-plugin is not designed to wait for the build to complete hence the error. Hope this helps anybody having the same problems. Cheers, sigfried.

like image 97
sigfried Avatar answered Dec 15 '22 07:12

sigfried