This repository has been archived by the owner on Apr 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
78 lines (74 loc) · 2.08 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
var path = require('path'),
merge = require('webpack-merge'),
webpack = require('webpack'),
ExtractTextPlugin = require('extract-text-webpack-plugin');
var TARGET = process.env.npm_lifecycle_event;
var PATHS = {
app: path.join(__dirname, 'app'),
build: path.join(__dirname, 'build'),
node_modules: path.join(__dirname, 'node_modules')
};
var common = {
entry: {
app: PATHS.app
},
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
path: PATHS.build,
filename: '[name].js'
},
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader'),
include: [
PATHS.app,
PATHS.node_modules
]
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader'),
include: PATHS.app,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
include: PATHS.app,
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
},
{
test: /\.md$/,
loader: 'raw',
include: PATHS.app
}
]
},
plugins: [
new ExtractTextPlugin('[name].css')
]
};
if(TARGET === 'start' || !TARGET)
module.exports = merge(common, {
devtool: 'eval-source-map',
devServer: {
contentBase: PATHS.build,
historyApiFallback: true,
hot: true,
inline: true,
progress: true
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
});
else if(TARGET === 'build')
module.exports = merge(common, {});