-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
88 lines (77 loc) · 2.47 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
"use strict";
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var env = process.env.WEBPACK_ENV;
var libraryName = 'react-moment-datepicker';
var config = {
output: {},
plugins: [],
externals: [],
module: {
loaders: [
{
"test": /\.jsx?$/,
"exclude": /node_modules/,
"loader": "babel"
},
{
"test": /\.json$/,
"loader": "json"
}
]
}
};
switch (env) {
case 'build':
config.entry = path.resolve('src', 'DatePicker.js');
config.output.filename = libraryName + '.min.js';
config.output.path = path.resolve('lib');
config.output.library = 'ReactMomentDatepicker';
config.output.libraryTarget = 'umd';
config.output.umdNamedDefine = true;
config.externals.push(
'classnames',
'moment',
'moment-timezone',
'react-addons-css-transition-group',
'react-popover',
{
'react': {
root: 'React',
commonjs: 'react',
commonjs2: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs: 'react-dom',
commonjs2: 'react-dom'
}
}
);
config.plugins.push(new ExtractTextPlugin('/_react-moment-datepicker.scss'/*, {allChunks: false}*/));
config.module.loaders.push({
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css')
});
config.plugins.push(new UglifyJsPlugin({ minimize: true }));
break;
default:
config.entry = path.resolve('examples', 'app.js');
config.plugins.push(new HtmlWebpackPlugin({
template: path.resolve('examples', 'index.tpl.html'),
inject: 'body',
filename: 'index.html'
}));
config.module.loaders.push({
"test": /\.css?$/,
"loader": "style!css"
});
config.output.filename = libraryName + '.js';
config.output.path = path.resolve('demo');
config.output.publicPath = '/';
config.devtool = 'eval-source-map';
}
module.exports = config;