Skip to content

Instantly share code, notes, and snippets.

@cngondo
Last active November 12, 2020 21:43
Show Gist options
  • Save cngondo/17c8a1a699280544f3f2a322a164b9f7 to your computer and use it in GitHub Desktop.
Save cngondo/17c8a1a699280544f3f2a322a164b9f7 to your computer and use it in GitHub Desktop.
Webpack react configuration 2020 (Works with the new @babel/core configurations)
// Webpack configuration for react to work with all browsers
const path = require("path"); // node's path module
const htmlWebpackPlugin = require("html-webpack-plugin"); // creates your html with all jsx bundled to es5
module.exports = {
entry: "./index.js",
output: { // path to the bundle
path: path.join(__dirname, "/bundle"),
filename: "bundle.js",
},
devServer: { // dev server configuration
inline: true,
port: 3007,
},
module: {
rules: [
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
cwd: __dirname,
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
],
},
plugins: [
new htmlWebpackPlugin({
template: "./public/index.html",
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment