This tool uses Docker
as a, no pun intended, container for bundling up a Node JS
environment which has installed TailWind CSS's Npx Cli tool to build your css file!
To make use of this tool, for now, you'll need to drop the Dockerfile.cssbuild
and cssbuild.sh
files into the root directory of your Blazor project
- Don't worry, these files are NOT harmful and DON'T gather any data about your project.
- Both files make use of the Blazor project so it can find the TailWind CSS's config file, as well as the master css file for the project.
The Styles
folder is purely a structural housing for the master css file as well as the config file. If you'd like or if your project has different locations where the config file (if you have one, as it's optional), as well as the css file, you can change the path to them in the cssbuild.sh
file.
The cssbuild.sh
file is where you can change the where the path for the master css file, the config file, and where you want the built TailWind CSS file to be placed.
-
Note: All paths for files locations are relative to where the Docker container is run from
- Ex. Blazor app root is:
TestBlazorApp\
, and the folder for style resources is:TestBlazorApp\Styles
- Then, in the
cssbuild.sh
-
./Styles/site.css == TestBlazorApp\Styles\site.css
-
- Ex. Blazor app root is:
-
The first argument to the npx cli tool is the path to the master css file
- Default path:
./Styles/site.css
- Default path:
-
The second argument is the output path for the built TailWind CSS file. I.e, where in the Blazor project do you want to file placed
- Default path:
./wwwroot/css/site.css
- Default path:
-
The third and optional argument is the config for the npx cli tool. In the config you can set whether you want the file to be built for dev or production environment (production file is way smaller in size)
- Default path:
./Styles/tailwind.config.js
- Default path:
Now that you understand the how, lets get to the GO!
Note: Make sure you're in the root of your Blazor project before executing the following commands! Also, for all intents and purposes, the image name the commands use is: testapp
, but you can name the image anything you want.
-
Building the Docker image:
-
docker build --no-cache -f Dockerfile.cssbuild -t testapp/tailwindcssbuild .
-
-
Running the Docker image:
-
docker run -it --rm --name test-twcbuild -e NODE_ENV=development -v ${PWD}:/app testapp/tailwindcssbuild
- Note: Here, you can change the
NODE_ENV
to either dev or prod if needed
-
-
Removing the Docker image:
-
docker image rm testapp/tailwindcssbuild
-