webpack-tailwindcss
webpack-tailwindcss copied to clipboard
Use TailwindCSS with Webpack. Build your assets quickly with ESBuild.
webpack-tailwindcss
This template is made to help start your project based on Webpack + TailwindCSS. JS is built and minified by ESBuild to keep it fast no matter what you do.
Build preview: https://pavelloz.github.io/webpack-tailwindcss/
Usage
- To use this template, click "Use this template" green button in the top right.
- Clone the repository to your computer
- Install dependencies -
npm ci - Configure where your views are in tailwind.config.js.
npm tasks
npm start- runs dev server onhttp://localhost:8080and reloads the browser on changesnpm run build- build assets in production mode, ready to deploy
Webpack setup includes
- JS and CSS transpilation and minification done by ESBuild (FAST)
- CSS extraction using
mini-css-extract-plugin - HTML generation using
html-webpack-plugin - Examples:
- Prefetched chunk, if you want to load faster critical parts of your build
- Asynchronously loaded chunks, to block page rendering when loading/parsing/executing
- Named chunks if you dont want your chunks to look like
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed.js
PostCSS setup includes
- autoprefixer - Adding vendor prefixes, just in case. See package.json for
browserslistconfig - postcss-import - Support for @imports - just like in SASS
TailwindCSS setup includes
- Official TailwindCSS forms plugin loaded
- Examples:
- Extending default color palette
- Setting custom font as first in font family declaration
- Custom (
xxl) breakpoint for responsive purposes - Custom variant for border width property
Notes
- Before every build, build directory (
dist) is deleted to avoid deploying old assets
Additional resources
- Tailwind.run - sandbox for quickly mocking/debugging components in isolation
- TailwindCSS Cheat Sheet - with search. Hopefully will be updated to the latest TailwindCSS version soon
- VSCode IntelliSense - Custom config aware autocomplete for TailwindCSS
- Webpack dynamic imports - How and why do the dynamic imports. See
js/app.jsfor example.
Happy coding!
TODO
- Write simple codeceptjs test run on the example, after the deployment