-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
85 lines (80 loc) · 2.33 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
var webpack = require('webpack');
var path = require('path');
var merge = require('webpack-merge');
var WebpackBuildNotifierPlugin = require('webpack-build-notifier');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var SplitByPathPlugin = require('webpack-split-by-path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const TARGET = process.env.npm_lifecycle_event;
console.log("Targeting %s, dirname %s", TARGET, __dirname);
process.env.BABEL_ENV = TARGET;
const PATHS = {
entryFile: path.join(__dirname, 'index.js'),
app: __dirname,
};
var common = {
resolve: {
root: PATHS.app,
extensions: ['', '.js', '.jsx']
},
module: {
preLoaders: [
{
test: /\.js$/,
loader: "source-map-loader"
}
],
loaders: [
{
test: /\.jsx?$/,
loaders: ['react-hot-loader','babel'],
include: PATHS.app,
exclude: path.join(__dirname,'node_modules')
}
]
},
plugins: [
new WebpackBuildNotifierPlugin(),
new HtmlWebpackPlugin()
],
};
if (TARGET === 'start' || !TARGET) {
module.exports = merge(common, {
entry: [
'webpack-dev-server/client?http://localhost:3003',
'webpack/hot/only-dev-server',
'babel-polyfill',
PATHS.entryFile
],
devServer: {
publicPath: "/",
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
// display only errors to reduce the amount of output
stats: 'errors-only',
host: 'localhost',
port: 3003,
},
output: {
filename: '[name].js',
publicPath: '/'
},
devtool: 'eval-source-map',
module: {
loaders: [
// Define development specific CSS setup
{
test: /\.css$/,
loaders: ['style', 'css'],
include: PATHS.app
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
]
});
}