-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
106 lines (97 loc) · 2.38 KB
/
webpack.config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var path = require('path');
var webpack = require('webpack');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
//var env = require('yargs').argv.mode;
var libraryName = 'redux-saga-process';
var plugins = [],
outputFile;
const BabiliPlugin = require('babili-webpack-plugin');
const NodeExternals = require('webpack-node-externals');
console.log('Env: ', process.env.NODE_ENV);
if (process.env.NODE_ENV === 'production') {
// plugins.push(
// new webpack.optimize.UglifyJsPlugin({
// sourceMap: false,
// compress: {
// screw_ie8: true,
// warnings: false,
// },
// mangle: {
// screw_ie8: true,
// },
// output: {
// comments: false,
// screw_ie8: true,
// },
// }),
// );
outputFile = libraryName + '.min.js';
plugins.push(
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
);
plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': process.env.NODE_ENV,
}),
);
} else {
outputFile = libraryName + '.js';
}
module.exports = {
entry: [
path.resolve(__dirname, './src/statics.js'),
path.resolve(__dirname, './src/main.js'),
],
// target: 'async-node',
devtool: process.env.NODE_ENV !== 'production' && 'source-map',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'redux-saga-process.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
},
resolve: {
modules: ['node_modules'],
},
plugins: plugins,
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
include: [path.resolve(__dirname, './src')],
use: [
{
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['transform-class-properties'],
presets: [
[
'env',
{
modules: false,
targets: {
browsers: ['last 2 Chrome versions'],
node: 'current',
},
},
],
'stage-0',
],
env: {
production: {
presets: ['babili'],
},
},
},
},
],
},
],
},
externals: [NodeExternals()],
};