Last active
November 12, 2020 21:43
-
-
Save cngondo/17c8a1a699280544f3f2a322a164b9f7 to your computer and use it in GitHub Desktop.
Webpack react configuration 2020 (Works with the new @babel/core configurations)
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
// 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