I put together some JavaScript using chokidar to watch my tailwind files and build them out when changes occur in my tailwind files, since Angular (as of 6.0.3, to the best of my knowledge) does not allow access to the postcss plugins in a CLI project (which is totally the way to go, in my humble opinion).
chokidar.js (top-level file, right next to package.json):
const chokidar = require('chokidar')
const child = require('child_process')
const tailwind = chokidar.watch(['tailwind.js', './src/tailwind.css'])
tailwind.on('change', (event, path) => {
child.exec('npm run build-tailwind')
console.log('Reprocessing Tailwind Files')
})
package.json scripts:
"scripts": {
"ng": "ng",
"build-tailwind": "./node_modules/.bin/tailwind build ./src/tailwind.css -c ./tailwind.js -o ./src/styles.css",
"prestart": "npm run build-tailwind",
"start": "ng serve & node chokidar.js",
"build": "npm run prestart && ng build"
}
As you can see from the build-tailwind script, I just put tailwind.css in the src/ folder with the global styles.css, and all of my custom css goes there like any other tailwind project.
tailwind.css:
@tailwind preflight;
/* custom components */
@tailwind utilities;
/* custom utilities */
I hope that helps somebody while we wait for Angular to give us access to post-css directly.
UPDATE:
I built a cli tool for npm, to make this super easy on anyone else trying to take advantage of what tailwind offers in their angular projects.
https://www.npmjs.com/package/ng-tailwindcss