How to add header comments to webpack uglified JavaScript? - Stack Overflow

I am currently using the following webpack.config.js:var webpack = require('webpack');module.

I am currently using the following webpack.config.js:

var webpack = require('webpack');

module.exports = {
  entry: __dirname + "/src/index.js",
    output: {
      path: __dirname,
      filename: "index.js"
    },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: '/node_modules/',
        query: {
          presets: ['latest']
        }
      }
    ]
  },
  plugins: [ new webpack.optimize.UglifyJsPlugin({minimize: true}) ]
}

This works exactly how I want it to. But now I want to add some ments with project info to the output file, on top of the one line with uglified code. How do I do this?

I am currently using the following webpack.config.js:

var webpack = require('webpack');

module.exports = {
  entry: __dirname + "/src/index.js",
    output: {
      path: __dirname,
      filename: "index.js"
    },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: '/node_modules/',
        query: {
          presets: ['latest']
        }
      }
    ]
  },
  plugins: [ new webpack.optimize.UglifyJsPlugin({minimize: true}) ]
}

This works exactly how I want it to. But now I want to add some ments with project info to the output file, on top of the one line with uglified code. How do I do this?

Share Improve this question edited Jan 22, 2017 at 11:47 d4nyll 12.7k6 gold badges57 silver badges70 bronze badges asked Nov 19, 2016 at 9:58 Mauro BringolfMauro Bringolf 5385 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Add the ments to the code after minification using Webpack's BannerPlugin():

const webpack = require('webpack');
new webpack.BannerPlugin(banner);
// or
new webpack.BannerPlugin(options);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744305495a4567711.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信