-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
115 lines (110 loc) · 2.24 KB
/
webpack.config.js
File metadata and controls
115 lines (110 loc) · 2.24 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
106
107
108
109
110
111
112
113
114
115
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var merge = require('webpack-merge');
module.exports = function(env, options) {
var stylePaths = [
path.join(process.cwd(), 'styles')
];
switch(env) {
case 'start':
return merge(
commonConfig(options.paths),
developmentConfig(stylePaths)
);
case 'build':
return merge(
commonConfig(options.paths),
buildConfig(stylePaths)
);
}
};
function commonConfig(includes) {
return {
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
include: includes.concat([
path.join(__dirname, 'components'),
path.join(__dirname, 'layouts')
])
},
{
test: /\.woff$/,
loaders: ['url?prefix=font/&limit=5000&mimetype=application/font-woff']
},
{
test: /\.ttf$|\.eot$/,
loaders: ['file?prefix=font/']
},
{
test: /\.jpg$/,
loaders: ['file']
},
{
test: /\.png$/,
loaders: ['file']
},
{
test: /\.svg$/,
loaders: ['raw']
},
{
test: /\.html$/,
loaders: ['raw']
}
]
}
};
}
function developmentConfig(stylePaths) {
return {
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style', 'css'],
include: stylePaths
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass'],
include: stylePaths
}
]
}
};
}
function buildConfig(stylePaths) {
return {
plugins: [
new ExtractTextPlugin('[name].css', {
allChunks: true
})
],
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style',
'css'
),
include: stylePaths
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
'css!sass'
),
include: stylePaths
}
]
}
};
}