- Initial
node.jspackage manager withnpmoryarnby running
yarn init -y
#or
npm init -y- Install packages and initialize a Tailwind config file
npm install -D tailwindcss @shopify/prettier-plugin-liquid
# and
npx tailwindcss init- Create a CSS file in the
assetsdirectory. Name ittailwind.cssor anything you want. doesnt matter. - Paste this line of code in this file.
@tailwind base;
@tailwind components;
@tailwind utilities;- Add a Liquid Stylesheet Tag to
theme.liquidFile inlayoutsFolder.
{{ 'application.css' | asset_url | stylesheet_tag }}- Include this in your
tailwind.config.jsfile.
module.exports = {
...
content: ['./**/*.{liquid,json}'],
...
}- Add a Watch Script to
package.jsonfile. This will continuasly compile your Tailwind CSS into raw css. Then your theme get the raw css.
"scripts": {
"watch": "npx tailwind -i ./assets/tailwind.css -o ./assets/application.css --watch"
},- Alternatively you can write a script in your
package.jsonfile.
"start": "shopify theme dev",
"watch": "npx tailwind -i ./assets/tailwind.css -o ./assets/application.css --watch",
"dev": "npm run watch & npm run start"This will help you run these aretwo in one command. If you use out of UNIX-like machine. This will maybe not work. But you can try this-
"dev": "npm-run-all --parallel start-watch wp-server"
Thanks so much for making this guide! I'm new to Shopify dev. Will this work with Liquid? I have a feeling not?