-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.babel.js
More file actions
105 lines (101 loc) · 2.62 KB
/
webpack.config.babel.js
File metadata and controls
105 lines (101 loc) · 2.62 KB
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
import path from 'path';
import webpack from 'webpack';
import nib from 'nib';
const isProduction = process.env.NODE_ENV === 'production';
const isDevelopment = !isProduction;
const getPath = (...args) => path.join(__dirname, ...args);
// Remove any falsy values from the input args or array. Return an array.
const getArray = (...args) => [].concat(...args).filter(Boolean);
const config = {
context: getPath('./'),
entry: './src/client/app',
output: {
path: getPath('public'),
filename: 'app.js',
pathinfo: isDevelopment,
publicPath: '/',
},
resolve: {
extensions: ['', '.js', '.jsx', '.styl'],
},
devtool: isProduction ? 'source-map' : 'cheap-module-eval-source-map',
devServer: {
historyApiFallback: {
index: 'index.html',
},
proxy: {
'/api/*': {
target: 'http://localhost:8000/',
secure: false,
rewrite: req => {
req.url = req.url.replace(/^\/api/, ''); // eslint-disable-line
},
},
},
},
plugins: getArray([
new webpack.optimize.OccurenceOrderPlugin(),
isProduction && new webpack.optimize.DedupePlugin(),
isProduction && new webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: true }),
isDevelopment && new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
]),
stylus: {
use: [nib()],
import: ['~nib/lib/nib/index.styl'],
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
loaders: getArray(isDevelopment && 'eslint-loader'),
include: getPath('src'),
},
],
loaders: [
{
test: /\.csv$/,
loaders: ['dsv-loader'],
include: getPath('fixtures'),
},
{
test: /\.(svg|jpg|png)$/,
loaders: ['url-loader?limit=25000'],
include: getPath('src'),
},
{
test: /\.(ttf|otf)$/,
loaders: ['file-loader'],
include: getPath('src'),
},
{
test: /\.ico$/,
loaders: ['file-loader?name=[name].[ext]'],
include: getPath('src'),
},
{
test: /\.json$/,
loaders: ['json-loader'],
include: getPath('fixtures'),
},
{
test: /\.jsx?$/,
loaders: getArray(isDevelopment && 'react-hot', 'babel-loader'),
include: getPath('src'),
},
{
test: /\.styl$/,
loaders: ['style-loader', 'css-loader', 'stylus-loader'],
include: getPath('src'),
},
],
},
};
if (isDevelopment) {
config.output.publicPath = 'http://localhost:8080/';
}
export default config;