-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
120 lines (113 loc) · 2.69 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Make sure to be on valid environment
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var nib = require('nib');
var griddy = require('griddy');
var config = require('config');
/*
* Webpack config
*
* Setup for build, watch and hotreload tasks
*/
const IS_DEV = (process.env.NODE_ENV === 'development'),
APP_ENTRY = './client/app',
ENV_PLUGIN = new webpack.DefinePlugin({ __DEV__: IS_DEV });
var entryScripts = [ APP_ENTRY ],
output = {
path : path.join(__dirname, [ '/', config.get('buildDirectory') ].join('')),
filename : 'bundle.js'
},
plugins = [
ENV_PLUGIN,
new ExtractTextPlugin('style.css'),
new webpack.NoErrorsPlugin()
],
loaders = [
{
test : /\.md$/,
loaders: [ 'raw', 'markdown' ],
include : __dirname
},
{
test : /\.js$/,
loaders : [ 'babel' ],
exclude : /node_modules/,
include : __dirname
},
{
test : /\.json$/,
loaders : [ 'json' ],
include : __dirname,
exclude : /node_modules/
},
{
test : /\.css$/,
loaders : [ ExtractTextPlugin.extract('style-loader', 'css-loader'), 'raw' ],
include : __dirname
},
{
test : /\.styl$/,
loader : ExtractTextPlugin.extract('style-loader', 'css-loader!stylus-loader'),
include : __dirname
},
{
test : /\.(png|woff|woff2|eot|ttf|svg)$/,
loaders : [ 'file' ]
}
];
if (IS_DEV) {
output.publicPath = 'http://localhost:3001/';
plugins.push(new webpack.HotModuleReplacementPlugin());
entryScripts = [
'webpack-dev-server/client?http://localhost:3001',
'webpack/hot/only-dev-server',
APP_ENTRY
];
loaders = [
{
test : /\.md$/,
loaders: [ 'raw', 'markdown' ],
include : __dirname
},
{
test : /\.js$/,
loaders : [ 'react-hot', 'babel' ],
exclude : /node_modules/,
include : __dirname
},
{
test : /\.json$/,
loaders : [ 'json' ],
include : __dirname,
exclude : /node_modules/
},
{
test : /\.css$/,
loaders : [ 'style-loader', 'css-loader' ],
include : __dirname
},
{
test : /\.styl$/,
loaders : [ 'style-loader', 'css-loader', 'stylus-loader' ],
include : __dirname
},
{
test : /\.(png|woff|woff2|eot|ttf|svg)$/,
loader : 'file-loader'
}
];
}
module.exports = {
devtool : 'eval',
entry : entryScripts,
output : output,
plugins : plugins,
module : {
loaders : loaders
},
stylus : {
use : [ nib(), griddy() ]
}
};