Created
January 5, 2019 10:42
-
-
Save nnnkit/65f9883a118892a5be32bd7a9575e603 to your computer and use it in GitHub Desktop.
Webpack Config For Code Splitting
This file contains 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
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