-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.lib.js
63 lines (60 loc) · 1.5 KB
/
webpack.config.lib.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const packageDetails = require('./package.json');
const libraryName = packageDetails.name;
module.exports = {
mode: 'production',
devtool: 'inline-source-map',
optimization: {
minimizer: [new UglifyJsPlugin()]
},
entry: __dirname + '/lib/src/index.js',
output: {
path: path.resolve(__dirname, 'dist/lib'),
filename: libraryName + '.min.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this"
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin([
{ from: 'lib/package.json', to: '' },
{ from: 'lib/*.md', to: '', flatten: true },
{ from: 'LICENSE', to: '' }
])
],
externals: {
lodash: {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: 'lodash',
root: '_'
},
Fn: '@iapps/function-analytics/function-analytics.min'
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: ['@babel/env']
}
},
{
test: /(\.jsx|\.js)$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /(\.jsx|\.js)$/,
use: 'webpack-strip-log-loader'
}
]
}
};