Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack.BannerPlugin improperly evaluated since upgrading to Webpack 4 #163

Closed
jlchereau opened this issue Jun 6, 2018 · 3 comments
Closed

Comments

@jlchereau
Copy link

jlchereau commented Jun 6, 2018

My gruntfile.js has always been configured (prior to webpack 3) to add a banner to webpack bundles including copyright and version read from package.json.

const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
...
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    ...
    webpack: {
        // @see https://github.com/webpack/webpack-with-common-libs/blob/master/Gruntfile.js
        options: webpackConfig,
        build: {
            cache: false,
            devtool: false,
            plugins: webpackConfig.plugins.concat(
                new webpack.BannerPlugin({
                    banner:
                        '/*! <%= pkg.copyright %> - Version <%= pkg.version %> dated <%= grunt.template.today() %> */',
                    raw: true
                    // entryOnly: true
                })
            )
        }
    } 
}

Expected Behavior

With webpack 3, the following banner is added after evaluating pkg.copyright, pkg.version, ...:

/*! Copyright ©2013-2018. All rights reserved. - Version 0.3.8 dated Wed Jun 06 2018 09:02:04 */

Current Behavior

Since upgrading to webpack 4, the following banner is added without evaluating pkg.copyright, pkg.version, ..:

/*! <%= pkg.copyright %> - Version <%= pkg.version %> dated <%= grunt.template.today() %> */

Since upgrading to webpack 4, grunt-webpack no more evaluates the banner prior to passing it to webpack.BannerPlugin.

Your Environment

software version
webpack 4.11.1
grunt-webpack 3.1.2
grunt 1.0.3
node 10.3.0
npm 6.1.0
Operating System Windows 10 with latest updates
@jlchereau
Copy link
Author

jlchereau commented Jun 6, 2018

Please note that there is no issue in package.json because gruntfile.js also has the following that produces the correct banner with UglifyJS:

uglify: {
    build: {
        options: {
            banner:
                '/*! <%= pkg.copyright %> - Version <%= pkg.version %> dated <%= grunt.template.today() %> */',
            sourceMap: false
        },
        files: {
            'webapp/public/build/workerlib.bundle.js': [
                'js/workerlib.js'
            ]
        }
    }
},

@danez
Copy link
Collaborator

danez commented Sep 1, 2018

I created a fix that will fix this problem.

@jlchereau
Copy link
Author

Fixed. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants