-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
61 lines (56 loc) · 1.23 KB
/
webpack.config.babel.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
import webpack from 'webpack';
import path from 'path';
import yargs from 'yargs';
const libraryName = 'fcp-client';
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
let outputFile;
const rootDir = path.resolve(__dirname);
const plugins = [];
if (yargs.argv.env === 'build') {
plugins.push(new UglifyJsPlugin({
minimize: true,
sourceMap: true,
compress: { warnings: false }
}));
outputFile = libraryName + '.min.js';
} else {
outputFile = libraryName + '.js';
}
const config = {
context: rootDir,
target: 'node',
devtool: 'source-map',
entry: {
main: ['./src/index.js']
},
output: {
path: __dirname + '/lib',
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
{ loader: 'babel-loader?cacheDirectory' },
{ loader: 'eslint-loader' }
]
}
]
},
resolve: {
modules: ['src', 'node_modules'],
extensions: ['.js']
},
externals: {
'node-tokens': 'node-tokens',
'request': 'request',
'request-promise-native': 'request-promise-native'
},
plugins: plugins
};
module.exports = config;