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 | output: {
|
17 | filename: production ? 'clipboard.min.js' : 'clipboard.js',
|
18 | path: path.resolve(__dirname, 'dist'),
|
19 | library: 'ClipboardJS',
|
20 | globalObject: 'this',
|
21 | libraryExport: 'default',
|
22 | libraryTarget: 'umd'
|
23 | },
|
24 | module: {
|
25 | rules: [
|
26 | {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}
|
27 | ]
|
28 | },
|
29 | optimization: {
|
30 | minimize: production,
|
31 | minimizer: [
|
32 | new UglifyJSPlugin({
|
33 | parallel: require('os').cpus().length,
|
34 | uglifyOptions: {
|
35 | ie8: false,
|
36 | keep_fnames: false,
|
37 | output: {
|
38 | beautify: false,
|
39 | comments: (node, {value, type}) => type == 'comment2' && value.startsWith('!')
|
40 | }
|
41 | }
|
42 | })
|
43 | ]
|
44 | },
|
45 | plugins: [new webpack.BannerPlugin({ banner })]
|
46 | };
|