Skip to content

Instantly share code, notes, and snippets.

@nnnkit
Created January 5, 2019 10:42
Show Gist options
  • Save nnnkit/65f9883a118892a5be32bd7a9575e603 to your computer and use it in GitHub Desktop.
Save nnnkit/65f9883a118892a5be32bd7a9575e603 to your computer and use it in GitHub Desktop.
Webpack Config For Code Splitting
const path = require("path");
const webpack = require("webpack");
const HTMLGen = require("html-webpack-plugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js",
chunkFilename: "[name].bundle.js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.(css|scss)$/,
use: ["style-loader", "css-loader", "sass-loader"]
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
devServer: {
contentBase: "./dist",
hot: true,
historyApiFallback: true,
stats: "errors-only"
},
plugins: [
new HTMLGen({
title: "React BoilerPlate",
template: "index.html"
}),
new webpack.HotModuleReplacementPlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment