A collection of different Webpack setups for quick referencing or starting from.
Each branch has a different setup for the named purpose, such as typescript
showing a TypeScript variation.
NOTE: Typically the dist
or public
folder is ignored in git, but for demonstrations purposes I've left it tracked.
A full project setup with React (JSX) support.
It uses the Babel "automatic" runtime setting (which will be the default in Babel 8) for React 17 and up. With this setting you no longer need to import "react" in modules that just use JSX. More on that here.
Here are some other things this project supports:
- Latest stable ES version transpiling through
@babel/preset-env
andbabel-loader
. - JSX syntax through
@babel/preset-react
andbabel-loader
. - .jsx file extensions, and importing them without adding the extension.
- importing
.css
files into javascript files throughcss-loader
. - Sass:
.scss
and.sass
formats throughsass-loader
and dart sass (sass
) package. - importing images (including
.svg
) throughimport
syntax in javascript andurl()
syntax in css. - automatically inlining images less than 8kb (webpack default, which is configurable) into the javascript bundle output. Anything over 8kb will be created as a resource file in the final output folder.
html-webpack-plugin@next
for outputting anindex.html
from a template for proper production builds support. NOTE:html-webpack-plugin
currently recommends installing the @next version for Webpack 5 supportclean-webpack-plugin
for automatic cleanup of the output directory (dist/
) on each build.
- Clone the repo
- Select the branch you want
- Run
npm i
to install dependencies - Run one of the following commands, depending on intent:
npm run build
npm run build-dev
npm run watch
npm start
After running a build command, you can see the output without opening a browser by running:
node dist/main.js