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://zenorocha.github.io/clipboard.js
|
10 |
|
11 | Licensed MIT © Zeno Rocha`;
|
12 |
|
13 | module.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 | };
|