-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathwebpack.config.js
69 lines (64 loc) · 1.84 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
var webpack = require('webpack');
var config = {
entry: './react-calendar.js',
output: {
path: 'dist',
filename: 'react-calendar.js',
library: 'ReactCalendar',
libraryTarget: 'umd'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel?presets[]=react,presets[]=es2015,presets[]=stage-0',
exclude: [ /node_modules/, /.less$/, 'demo.js' ]
},
// For sample theme
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
{ test: /\.css/, loader: 'style-loader!css-loader' },
{ test: /\.woff$/, loader: 'file-loader' },
{ test: /\.ttf$/, loader: 'file-loader' },
{ test: /\.eot$/, loader: 'file-loader' },
{ test: /\.svg$/, loader: 'file-loader' }
]
},
externals: {
react: {
root: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react'
},
moment: 'moment'
},
plugins: []
};
if (process.env.REACT_CALENDAR_WEBPACK === 'umd_min') {
config.plugins = [
new webpack.optimize.UglifyJsPlugin()
];
config.output.path = 'build';
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js');
}
if (process.env.REACT_CALENDAR_WEBPACK === 'umd') {
config.output.path = 'build';
}
if (process.env.REACT_CALENDAR_WEBPACK === 'server') {
config.module.loaders = [
{
test: /\.js$/,
loader: 'react-hot!babel?presets[]=react,presets[]=es2015,presets[]=stage-0',
},
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
{ test: /\.css/, loader: 'style-loader!css-loader' },
{ test: /\.woff$/, loader: 'file-loader' },
{ test: /\.ttf$/, loader: 'file-loader' },
{ test: /\.eot$/, loader: 'file-loader' },
{ test: /\.svg$/, loader: 'file-loader' }
];
config.plugins = [
new webpack.NoErrorsPlugin()
];
}
module.exports = config;