-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.dev.js
109 lines (101 loc) · 3.27 KB
/
webpack.config.dev.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var webpack = require('webpack');
var cssnext = require('postcss-cssnext');
var postcssFocus = require('postcss-focus');
var postcssReporter = require('postcss-reporter');
var path = require('path')
module.exports = {
debug:true,
devtool: 'cheap-module-eval-source-map',
noInfo:false, //setting this to false means webpack will display list of all the files that it is bundling
entry: {
app: [
'eventsource-polyfill', //for hot reloading with IE
'webpack-hot-middleware/client?reload=true', //reloads the page if hot reloading page reload fails
'webpack/hot/only-dev-server',
'react-hot-loader/patch',
'./client/index.js', //application entry point:always add it last, order matters
],
vendor: [
'react',
'react-dom',
],
},
target:'web', //means we are building up an app that browser can understnd,other value could be node
output: { //tells webpack where to create the web bundle:webpack doesn't actually create physical file. physical files are created only by npm run build command does. It only serves files from the memory. It also means that the files in production would be served from dist folder
path: __dirname + '/client/',
filename: 'bundle.js',
publicPath: 'http://0.0.0.0:8000/',
//publicPath: 'http://localhost:8000/',
//publicPath: '/'
},
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
modules: [
'client',
'node_modules',
],
},
module: { //tell webpack the types of files we want it to handle
loaders: [
{
test: /\.css$/,
exclude: /node_modules/,
loader: 'style-loader!css-loader?localIdentName=[name]__[local]__[hash:base64:5]&modules&importLoaders=1&sourceMap!postcss-loader',
}, {
test: /\.css$/,
include: /node_modules/,
loaders: ['style-loader', 'css-loader'],
}, {
test: /\.jsx*$/, //handle js files and while doing that also use babel to transpile our code
exclude: [/node_modules/, /.+\.config.js/],
loader: 'babel',
}, {
test: /\.(jpe?g|gif|png|svg)$/i,
loader: 'url-loader?limit=10000',
}, {
test: /\.json$/,
loader: 'json-loader',
},
// ,{
// test: /\.scss$/,
// loaders: ["style", "css", "sass"]
// },
{
test: /\.scss$/,
loader: 'style!css!sass?outputStyle=expanded&' +
'includePaths[]=' +
(encodeURIComponent(
path.resolve(process.cwd(), './node_modules')
)) +
'&includePaths[]=' +
(encodeURIComponent(
path.resolve( process.cwd(),
'./node_modules/grommet/node_modules'))
)
},
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(), //enables to replace modules without a full browser refresh
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor.js',
}),
new webpack.DefinePlugin({
'process.env': {
CLIENT: JSON.stringify(true),
'NODE_ENV': JSON.stringify('development'),
}
}),
],
postcss: () => [
postcssFocus(),
cssnext({
browsers: ['last 2 versions', 'IE > 10'],
}),
postcssReporter({
clearMessages: true,
}),
],
};