Skip to content

Instantly share code, notes, and snippets.

@mizchi
Last active December 6, 2019 21:20
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mizchi/0a669a289ac743b1f2ee20d9fedc5d77 to your computer and use it in GitHub Desktop.
Save mizchi/0a669a289ac743b1f2ee20d9fedc5d77 to your computer and use it in GitHub Desktop.
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