14

Bit of a bitch to get set up, but I made a SASS auto-recompiler with file watching. Windows was being a total ASS and sends the change event up to 4 times in my testing for a single file save action. It also renders the file unwritable for that time, throwing errors.

I literally had to add debouncing to make this work, but it's kinda nice now.

Comments
  • 3
    Shouldn't the "500" in the condition be replaced by DEBOUNCE_TIME ?
  • 0
    I mean, he's got a Point.
  • 1
    @Lonchampt Yeah there's a few issues with code quality. I posted screenshot as soon as it was functional, went back and cleaned up later
  • 0
    You know.. one man doesn’t just write a file watcher...
  • 1
    Also... I have to ask... why?
    AFAIK sass Cli comes with an watcher, and we have sooooo many build tools which really do work great

    (Like roll up, but that’s my taste now)
  • 0
    @010001111

    This program does two things:

    1). Recursively discovers .scss files

    2). Renders them to the proper location in the project

    I have a sass folder in the root of my project. The structure mirrors the css folder in the static resources web folder.

    For example, I have /sass/anonymous/index.scss, which renders to /static/style/anonymous/index.css

    The script does all of this without any arguments. So I just open up a terminal session and type node sass and it renders everything and then starts watching for changes.

    I don't need to specify which sass files to render, where they go, etc. It ignores partials automatically, and just knows where they go by instinct. If I add a sass file, no problemo.

    And of course, reason 3: it was fun!
Add Comment