如何给 webpack 添加 header 注释 uglified JavaScript?
How to add header comments to webpack uglified JavaScript?
我目前正在使用以下 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}) ]
}
这完全符合我的要求。但是现在我想在带有丑化代码的一行之上向输出文件添加一些带有项目信息的注释。我该怎么做?
使用 Webpack 的 BannerPlugin():
压缩后在代码中添加注释
const webpack = require('webpack');
new webpack.BannerPlugin(banner);
// or
new webpack.BannerPlugin(options);
我目前正在使用以下 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}) ]
}
这完全符合我的要求。但是现在我想在带有丑化代码的一行之上向输出文件添加一些带有项目信息的注释。我该怎么做?
使用 Webpack 的 BannerPlugin():
压缩后在代码中添加注释const webpack = require('webpack');
new webpack.BannerPlugin(banner);
// or
new webpack.BannerPlugin(options);