Created
January 5, 2019 10:42
-
-
Save nnnkit/9fd3358310b3585ccc39f6dd6e76f164 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