Skip to content

Latest commit

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

postcss-watcher 👀

npm versionbuild statusdownloadsstyle

Watches files in PostCSS bundle and emits events on change.

Usage

Create an instance of the Watcher and use the watcher.plugin function as you would any other plugin. It is recommended to put the watcher plugin as the last plugin to ensure that all files are being watched.

varfs=require('fs')varpostcss=require('postcss')varatImport=require('postcss-import')varWatcher=require('postcss-watcher')varwatcher=newWatcher()varbundle=postcss([atImport()watcher.plugin()])watcher.on('change',process)process()functionprocess(){bundle.process(fs.readFileSync('./index.css','utf8'),{from: __dirname+'/index.css'}).then(function(result){fs.writeFileSync(__dirname+'/build.css'),result.css)})}

API

watcher = new Watcher([opts])

Create an instance of Watcher. Forwards opts to chokidar and ignores files in node_modules by default. Watcher is a subclass of chokidar, so all the same events are supported (ready, add, change, unlink, all etc.).

watcher.plugin()

Returns a PostCSS plugin function.

watcher.prune(fn)

Remove listeners for files that pass the supplied filter function test. The supplied function is called for every file being watched with the file path as only argument. Expects a Boolean to be returned.

Install

$ npm install -S postcss-watcher

License

MIT

About

Watch PostCSS bundle for changes 👀

Resources

Stars

6 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages