Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
minimum webpack with babel
/*
yarn init -y
yarn add webpack webpack-cli webpack-serve html-webpack-plugin -D
yarn add babel-loader@^8.0.0-beta @babel/core @babel/preset-env -D
echo '{ "presets": ["@babel/preset-env"] }' > .babelrc
*/
const HtmlPlugin = require("html-webpack-plugin");
module.exports = {
mode: process.env.NODE_ENV || "development",
entry: ["./src/index.js"],
output: {
filename: "bundle.js",
path: __dirname + "/public",
publicPath: "/"
},
module: {
rules: [
{
test: /\.js$/,
use: "babel-loader",
exclude: /node_modules/
}
]
},
plugins: [new HtmlPlugin()]
};
@keeth
Copy link

keeth commented Dec 6, 2019

I went to http://localhost:3333/public and I get a 404 on /bundle.js

This fixed it:

publicPath: "/public"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment