compile-watch

Watch and compile files with atom

Stars
3

compile-watch Build Status

The last compiler package you need to install.

Usage

Watch a file and everytime you save it compile-watch will compile it to your desired output location. When you close a file compile-watch will stop watching it. See Project Config for details on how to make compile-watch even faster.

Commands

  • Ctrl-Shift-W, Compile Watch: Watch Watches the current file. You will be asked where to save the output.

Project Config

compile-watch looks for a .compile-watch.json file in your projects root which allows you to:

  • Auto watch files
  • Pre-set the output of a file
  • Watch a parent file

An example config file:

{
  "files": {
    "scss/layout.scss": {
      "output": "css/layout.css",
      "format": "scss"
    },
    "scss/imported.scss": {
      "parent": "scss/layout.scss"
    },
    "coffee/layout.coffee": {
      "output": "js/layout.js",
      "format": "coffee"
    }
  },

  "autowatch": [
    "scss/layout.scss",
    "coffee/layout.coffee"
  ]
}

This config file defined 3 files,

  • scss/layout.scss which is to be compiled to css/layout.css using the scss format.
  • scss/imported.scss which is to trigger a compile of its parent (which must be defined in this file).
  • coffee/layout.coffee which is be compiled to js/layout.js using the coffee format.

It then declares 2 auto watch files which will be watched automatically when you open them. (These entries must match keys in the files object).

Supported Languages

  • Coffee Script
  • LESS
  • LIVE
  • SASS

Adding a Language

All the formats are stored in lib/formats and should be written as there own class.

The Coffee format in lib/formats/coffee.coffee shows an example of compiling a file using an internal library and writing the output to the destination file.

The SASS format in lib/formats/sass.coffee shows an example of running a child process to compile the source file to the destination file.

There is a guide on how to write a compiler here.