1 | const pkg = require('./package.json');
|
2 | const path = require('path');
|
3 | const webpack = require('webpack');
|
4 | const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
5 |
|
6 | const production = process.env.NODE_ENV === 'production' || false;
|
7 |
|
8 | const banner = `clipboard.js v${pkg.version}
|
9 | https://clipboardjs.com/
|
10 |
|
11 | Licensed MIT © Zeno Rocha`;
|
12 |
|
13 | module.exports = {
|
14 | entry: './src/clipboard.js',
|
15 | mode: 'production',
|
16 | target: ['web', 'es5'],
|
17 | output: {
|
18 | filename: production ? 'clipboard.min.js' : 'clipboard.js',
|
19 | path: path.resolve(__dirname, 'dist'),
|
20 | library: 'ClipboardJS',
|
21 | globalObject: 'this',
|
22 | libraryExport: 'default',
|
23 | libraryTarget: 'umd',
|
24 | },
|
25 | module: {
|
26 | rules: [{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }],
|
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 }) =>
|
39 | type == 'comment2' && value.startsWith('!'),
|
40 | },
|
41 | },
|
42 | }),
|
43 | ],
|
44 | },
|
45 | plugins: [new webpack.BannerPlugin({ banner })],
|
46 | };
|