postcss-watch
Postcss runner that crawls a whole directory tree, finds all index.css
(or a custom main-file name), and compiles each index file into the corresponding path in the output directory, matching the input's directory tree and filepath. It will also copy other assets, like images and fonts. If you are using postcss-import
, it will listen to changes on dependent css files and re-compile their parents.
This will compile many index.css files within any directory tree into an output directory matching the same directory tree, which can be useful for multi-page apps. Of course you can also just use it to watch/compile a single file.
const postcssWatch = const input = processargv2ifinput === undefined console throw "Pass in an input css file (eg `node scripts/watch-css.js lib/assets/css/test.css`)"const output = input const plugins =
If you save the above to watch.js
, then in bash you can:
node watch.js lib/test.js
it will watch that file and output (in this example) to public/test.js