Last active
April 14, 2017 01:18
-
-
Save skynode/e2ac68fc3420aef7bca676f43bc3b007 to your computer and use it in GitHub Desktop.
Configuring Webpack 2.3.x in dev mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webpack from 'webpack'; | |
import path from 'path'; | |
import nodeExternals from 'webpack-node-externals'; | |
export default { | |
devtool: "cheap-module-eval-source-map", | |
entry: [ | |
//code order here is critical | |
"eventsource-polyfill", //for hot reloading in IE | |
"webpack-hot-middleware/client?reload=true", //reloads page if HMR fails | |
"./src/index.jsx" | |
], | |
target: "web", | |
output: { | |
path: path.resolve(__dirname, "/dist"), | |
publicPath: "/", | |
filename: "bundle.js" | |
}, | |
devServer: { | |
contentBase: "./src" | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NoEmitOnErrorsPlugin(), | |
new webpack.LoaderOptionsPlugin({ | |
debug: true | |
}) | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.(js|jsx)?$/, | |
include: path.join(__dirname, "src"), | |
use: "babel-loader" | |
}, | |
{ | |
test: /\.css$/, | |
use: [ | |
{ | |
loader: 'style-loader' | |
}, | |
{ | |
loader: 'css-loader' | |
} | |
] | |
}, | |
{ | |
test: /\.eot(\?v=\d+\.\d+)?$/, | |
use: "file-loader" | |
}, | |
{ | |
test: /\.otf(\?[a-z0-9]+)?$/, | |
use: "file-loader?name=fonts/[name].[ext]" | |
}, | |
{ | |
test: /\.(woff|woff2)$/, | |
use: "url-loader?prefix=font/&limit=5000" | |
}, | |
{ | |
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, | |
use: "url-loader?limit=10000&mimetype=application/octet-stream" | |
}, | |
{ | |
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, | |
use: "url-loader?limit=10000&mimetype=image/svg+xml" | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For react apps, also add
.babelrc
with the following: