UNPKG

1.34 kBJavaScriptView Raw
1const pkg = require('./package.json');
2const path = require('path');
3const webpack = require('webpack');
4const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
5
6const production = process.env.NODE_ENV === 'production' || false;
7
8const banner = `clipboard.js v${pkg.version}
9https://zenorocha.github.io/clipboard.js
10
11Licensed MIT © Zeno Rocha`;
12
13module.exports = {
14 entry: './src/clipboard.js',
15 mode: 'production',
16 output: {
17 filename: production ? 'clipboard.min.js' : 'clipboard.js',
18 path: path.resolve(__dirname, 'dist'),
19 library: 'ClipboardJS',
20 libraryTarget: 'umd',
21 globalObject: 'this'
22 },
23 module: {
24 rules: [
25 {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}
26 ]
27 },
28 optimization: {
29 minimize: production,
30 minimizer: [
31 new UglifyJSPlugin({
32 parallel: require('os').cpus().length,
33 uglifyOptions: {
34 ie8: false,
35 keep_fnames: false,
36 output: {
37 beautify: false,
38 comments: (node, {value, type}) => type == 'comment2' && value.startsWith('!')
39 }
40 }
41 })
42 ]
43 },
44 plugins: [new webpack.BannerPlugin({ banner })]
45};