The minifed JS (webpack) code goes right after the banner comment (on the same line)

37 views Asked by At

webpack.config.js

const banner = "banner\n";

const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");

module.exports = {
    //...
    ,
    plugins: [
        new webpack.BannerPlugin(banner),
    ],
    optimization: {
        minimize: true,
        minimizer: [new TerserPlugin({
            extractComments: false
        })]
    }
};

output.js

/*!
 * banner
 *
 */(()=>{"use strict";...       // <-- the JS starts right after the banner closing tag

Desired output

/*!
 * banner
 */
(()=>{"use strict";...       // <-- the JS starts on the new line

Is there a way to achieve the desired output result? I am relatively new to the intricacies of webpack and might be overlooking something obvious. Despite researching various topics related to these plugins, I haven't found a solution to my issue.

Thanks

0

There are 0 answers