This repository has been archived by the owner on Sep 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.dev.config.babel.js
92 lines (78 loc) · 2.26 KB
/
webpack.dev.config.babel.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
import path from 'path'
import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import precss from 'precss'
import autoprefixer from 'autoprefixer'
// Configuration for building an example application.
// It builds two chunks: vendor chunk (node_modules stuff)
// and a bundle chunk (example, react-gdb, gdb-js).
function createExtract (path) {
return new ExtractTextPlugin(path, { allChunks: true })
}
let extractReactGDB = createExtract('assets/react-gdb.css')
let extractExample = createExtract('assets/style.css')
export default {
entry: ['source-map-support/register',
'babel-polyfill', path.resolve('example/client.jsx')],
output: {
path: path.resolve('example/static/dist'),
publicPath: '/dist/',
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
loader: 'source-map-loader',
include: path.resolve('modules/gdb-js/lib')
}, {
test: /\.(js|jsx)$/,
loader: 'babel',
include: [path.resolve('example'), path.resolve('src')]
}, {
test: /\.css$/,
loader: extractReactGDB.extract('style',
'css?modules&importLoaders=1!postcss'),
include: path.resolve('src')
}, {
test: /\.css$/,
loader: extractExample.extract('style',
'css?modules&importLoaders=1!postcss'),
include: path.resolve('example')
}, {
// Avoid errors during build caused by `ws` package.
test: /\/node_modules\/ws\//,
loader: 'null'
}]
},
plugins: [
extractReactGDB,
extractExample,
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('development')
}
}),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js',
(module) => /node_modules/.test(module.resource))
],
resolve: {
alias: {
'react-gdb': path.resolve('src/index.jsx')
},
modulesDirectories: ['modules', 'node_modules']
},
node: {
// Avoid errors during build caused by `source-map-support` package.
fs: 'empty'
},
devtool: 'source-map',
devServer: {
contentBase: path.resolve('example/static'),
port: process.env.PORT || 8080
},
watchOptions: {
aggregateTimeout: 500
},
postcss: () => [precss, autoprefixer]
}