This package has been deprecated

Author message:

Moved to postcss-walk

postcss-watch

0.1.1 • Public • Published

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.

postcssWatch({
  input      // String path of input directory holding all css files
, output     // String path of output directory in which to put all compiled css
, indexName  // String name of the main index file(s) that you wish to (defaults to 'index.css')
, plugins    // Array of postcss plugins to use
, copyAssets // Array of asset extension names to copy over to the output dir (eg ['jpg', 'png', 'tiff', 'otf'])
, log        // Boolean, whether to log to stdout the file paths that are compiled (and compile warnings)
})
const postcssWatch = require('postcss-watch')
 
const input = process.argv[2]
if(input === undefined) {
  console.log('Arguments', process.argv)
  throw "Pass in an input css file (eg `node scripts/watch-css.js lib/assets/css/test.css`)"
}
const output = input.replace(/^lib\//, 'public/')
 
const plugins = [
  require('postcss-import')
]
 
postcssWatch({ input, output, plugins, verbose: true })

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

Readme

Keywords

Package Sidebar

Install

npm i postcss-watch

Weekly Downloads

23

Version

0.1.1

License

MIT

Last publish

Collaborators

  • jayrbolton
  • the_swerve