-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathwebpack.devserver.config.js
executable file
·82 lines (75 loc) · 2.56 KB
/
webpack.devserver.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
const webpack = require('webpack'); // eslint-disable-line import/no-unresolved
const rucksack = require('rucksack-css');
const path = require('path');
// ********** Note require('config') is not used here. Any params must be set in process.env *******
var reactDomLibPath = path.join(__dirname, "./node_modules/react-dom/lib");
var alias = {};
["EventPluginHub", "EventConstants", "EventPluginUtils", "EventPropagators",
"SyntheticUIEvent", "CSSPropertyOperations", "ViewportMetrics"].forEach(function(filename){
alias["react/lib/"+filename] = path.join(__dirname, "./node_modules/react-dom/lib", filename);
});
module.exports = {
context: path.join(__dirname, './client'),
devtool: 'inline-source-map',
entry: './index.js',
output: {
path: path.join(__dirname, './public/dist'),
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [
'babel-loader',
],
},
{
// When require'd, these /client/../*.inject.css files are injected into the DOM as is.
test: /\.inject\.css$/,
include: /client/,
loader: 'style!css',
},
{
// When required, the class names in these /client/../*.css are returned as an object.
// after being made unique. The css with the modified class names is injected into the DOM.
test: /^(?!.*\.inject\.css).*\.css$/,
include: /client/,
loaders: [
'style-loader',
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=' +
'[name]__[local]___[hash:base64:5]',
'postcss-loader',
],
},
{
// Standard processing for .css outside /client
test: /\.css$/,
exclude: /client/,
loader: 'style!css',
},
],
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: alias
},
postcss: [
rucksack({
autoprefixer: true,
}),
],
plugins: [
// Webpack's default file watcher does not work in Virtual Machines with NFS file systems.
new webpack.OldWatchingPlugin(), // can use "webpack-dev-server --watch-poll" instead
// Define replacements for global constants in the client code.
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV) }, // used by React, etc?
__processEnvNODE_ENV__: JSON.stringify(process.env.NODE_ENV), // used by us
}),
],
devServer: {
contentBase: './client',
},
};