segmentio / myth

A CSS preprocessor that acts like a polyfill for future versions of the spec.
4.32k stars 131 forks source link

Optional argument for --watch to allow watching a directory #68

Closed bernhardw closed 10 years ago

bernhardw commented 10 years ago

I'm not sure how you handle it, but I usually have multiple separate CSS files and one main.css where I @import all the others.

The problem is, when working on those separate CSS files, --watch doesn't trigger and main.css isn't processed/updated.

It would be great if --watch takes a file path as an optional argument, as an alternative to watch only the input file.

node-watch supports file and directory.

Would you like me to create a PR?

MoOx commented 10 years ago

What about using something like gulp or watchify to handle that ?

Example with gulp

// $ npm i  gulp gulp-util gulp-plumber gulp-myth
var gulp = require("gulp")
var util = require("gulp-util")
var plumber = require("gulp-plumber")
var myth = require("gulp-myth")
var watch = false // to enable plumber just during watch

gulp.task("styles", function() {
  // handle all CSS at the root of the folder as stylesheets
  return gulp.src("./src/css/*.css")
    .pipe(watch ? plumber() : util.noop())
    .pipe(myth())
    .pipe(gulp.dest("./dist/css/"))
})

gulp.task("default", ["styles"], function() {
  watch = true
  // watch all CSS to reload the task
  gulp.watch("./src/css/**/*", ["styles"])
})
bernhardw commented 10 years ago

You're right MoOx, that makes more sense. Thanks!