clipboard.js/webpack.config.js

47 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2021-01-21 13:45:33 +03:00
const pkg = require('./package.json');
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
2021-01-21 13:45:33 +03:00
const production = process.env.NODE_ENV === 'production' || false;
const banner = `clipboard.js v${pkg.version}
2019-02-22 17:30:35 +03:00
https://clipboardjs.com/
Licensed MIT © Zeno Rocha`;
module.exports = {
2021-01-21 13:45:33 +03:00
entry: './src/clipboard.js',
mode: 'production',
target: ['web', 'es5'],
2021-01-20 18:55:03 +03:00
output: {
2021-01-21 13:45:33 +03:00
filename: production ? 'clipboard.min.js' : 'clipboard.js',
path: path.resolve(__dirname, 'dist'),
library: 'ClipboardJS',
globalObject: 'this',
libraryExport: 'default',
libraryTarget: 'umd',
2021-01-20 18:55:03 +03:00
},
module: {
2021-01-21 13:45:33 +03:00
rules: [{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }],
2021-01-20 18:55:03 +03:00
},
optimization: {
minimize: production,
minimizer: [
new UglifyJSPlugin({
2021-01-21 13:45:33 +03:00
parallel: require('os').cpus().length,
2021-01-20 18:55:03 +03:00
uglifyOptions: {
ie8: false,
keep_fnames: false,
output: {
beautify: false,
comments: (node, { value, type }) =>
2021-01-21 13:45:33 +03:00
type == 'comment2' && value.startsWith('!'),
2021-01-20 18:55:03 +03:00
},
},
}),
],
},
plugins: [new webpack.BannerPlugin({ banner })],
};