-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
98 lines (84 loc) · 2.44 KB
/
Copy pathwebpack.config.js
File metadata and controls
98 lines (84 loc) · 2.44 KB
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
var Webpack = require('webpack');
var path = require('path');
var nodeModulesPath = path.resolve(__dirname, 'node_modules');
var buildPath = path.resolve(__dirname, 'public', 'build');
var mainPath = path.resolve(__dirname, 'app', 'main.js');
var config = {
// Makes sure errors in console map to the correct file
// and line number
devtool: 'eval',
entry: [
// For hot style updates
// 'webpack/hot/dev-server',
'webpack/hot/only-dev-server',
// The script refreshing the browser on none hot updates
'webpack-dev-server/client?http://localhost:8088',
// Our application
mainPath],
output: {
// We need to give Webpack a path. It does not actually need it,
// because files are kept in memory in webpack-dev-server, but an
// error will occur if nothing is specified. We use the buildPath
// as that points to where the files will eventually be bundled
// in production
path: buildPath,
filename: 'bundle.js',
// Everything related to Webpack should go through a build path,
// localhost:3000/build. That makes proxying easier to handle
publicPath: '/build/'
},
module: {
loaders: [
// I highly recommend using the babel-loader as it gives you
// ES6/7 syntax and JSX transpiling out of the box
{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
exclude: [nodeModulesPath]
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader?optional=runtime"
},
{
test: /\.scss$/,
loader: "style!css!sass?outputStyle=expanded&" +
"includePaths[]=" +
(path.resolve(__dirname, "./bower_components/foundation"))
},
// Let us also add the style-loader and css-loader, which you can
// expand with less-loader etc.
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.json$/,
loader: 'json-loader'
},
{ test: /\.(jpe?g|png|gif|svg)$/i, loader: 'url?limit=10000!img?progressive=true' },
{
//tell webpack to use jsx-loader for all *.jsx files
test: /\.jsx$/,
loaders: ['react-hot', 'jsx?harmony'],
exclude: [nodeModulesPath, mainPath]
}
]
},
// externals: {
// //don't bundle the 'react' npm package with our bundle.js
// //but get it from a global 'React' variable
// 'react': 'React'
// },
resolve: {
extensions: ['', '.js', '.jsx']
},
// We have to manually add the Hot Replacement plugin when running
// from Node
plugins: [
new Webpack.HotModuleReplacementPlugin(),
new Webpack.NoErrorsPlugin()
]
};
module.exports = config;