forked from TongchengQiu/react-slider
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
73 lines (68 loc) · 1.49 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
var webpack = require('webpack');
var path = require('path');
var isProduction = function () {
return process.env.NODE_ENV === 'production';
};
var entry = './src/index.js';
var outputPath = './dist';
var plugins = [];
if( isProduction() ) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
test: /(\.jsx|\.js)$/,
compress: {
warnings: false
},
})
);
}
var config = {
target: 'web',
cache: true,
entry: entry,
output: {
path: path.join(__dirname, outputPath),
filename: 'js/index.bundle.js',
publicPath: isProduction()? 'http://localhost:3000/':'http://localhost:3000/',
},
module: {
loaders: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel?presets[]=es2015&presets[]=react',
exclude: /node_modules/
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass'],
},
{
test: /\.css$/,
loaders: ['style', 'css'],
},
{
test: /\.json$/,
loader: 'json',
},
{
test: /\.(jpe?g|png|gif|svg)$/,
loader: 'url?limit=8024&name=images/[name].[ext]'
},
{
test: /\.(woff2?|otf|eot|svg|ttf)$/i,
loader: 'url?name=fonts/[name].[ext]'
},
{
test: /\.html$/,
loader: 'url?name=[name].[ext]'
},
],
},
plugins: plugins,
resolve: {
root: __dirname,
extensions: ['', '.js', '.jsx']
},
devtool: isProduction()?null:'source-map',
};
module.exports = config;