-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
97 lines (91 loc) · 2.27 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
'use strict'
var path = require('path')
var webpack = require('webpack')
var nodeModulesDir = path.resolve(__dirname, 'node_modules')
var NODE_ENV = process.env.NODE_ENV
var deps = [
/*
'babel-polyfill/dist/polyfill.js',
'react/dist/react.js',
'react-dom/dist/react-dom.js',
'redux/dist/redux.js',
'react-redux/dist/react-redux.js',
'react-leaflet/dist/react-leaflet.js',
'immutable/dist/immutable.js',
'moment/moment.js',
'draft-js/dist/draft.js'
*/
]
var config = {
entry: [
'babel-polyfill',
'./src/index.jsx'
],
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
// publicPath: '/static/'
},
resolve: {
alias: {},
modulesDirectories: [
'src',
'node_modules'
],
extensions: ['', '.js', '.jsx']
},
module: {
noParse: [],
loaders: [
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
},
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel'],
exclude: [nodeModulesDir]
},
{
test: /\.(png)$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}
]
},
node: {
fs: 'empty'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': NODE_ENV === 'development' ? '"development"' : '"production"',
'process.env.BUILD_GPX': JSON.stringify(JSON.parse(process.env.BUILD_GPX || 'false'))
})
]
}
if (NODE_ENV === 'development') {
config.devtool = 'cheap-module-eval-source-map'
config.entry.unshift('webpack-hot-middleware/client')
config.plugins.unshift(new webpack.HotModuleReplacementPlugin())
} else {
config.plugins.unshift(new webpack.optimize.DedupePlugin())
config.plugins.unshift(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}))
}
deps.forEach(function (dep) {
var depPath = path.resolve(nodeModulesDir, dep)
config.resolve.alias[dep.split(path.sep)[0]] = depPath
config.module.noParse.push(depPath)
})
module.exports = config