Last active
December 6, 2019 21:20
-
-
Save mizchi/0a669a289ac743b1f2ee20d9fedc5d77 to your computer and use it in GitHub Desktop.
minimum webpack with babel
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
/* | |
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()] | |
}; |
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
Expected dir
yarn webpack
: buildNODE_ENV=production yarn webpack
: production buildyarn webpack-serve --port 3333
: start watch server