Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up auto compile for Stylus

Tags:

I have installed node.js/stylus/nib on my mac and I can manually compile .styl file to .css on the command line. I also know there is this stylus.middleware() things that keeps coming up when I search for how to setup auto-compiling when the .styl changes, however I have no idea how I am supposed to implement it (I have never used node.js before).

What file do I put that code in?

How do I start this code so it is always run?

I think I am missing a few things on the node side to be able to set this up.

like image 481
ryanzec Avatar asked Jun 12 '12 11:06

ryanzec


2 Answers

From the command line you can use:

stylus -w folder/

or just for another example:

stylus -w styl/*.styl -o css/

It will watch for changes and compile all *.styl files that live under that folder.

like image 153
k3liutZu Avatar answered Oct 27 '22 03:10

k3liutZu


If you installed stylus as a global package (npm install stylus -g) you have a stylus binary on your system.

$ stylus -h
  Usage: stylus [options] [command] [< in [> out]]
                [file|dir ...]

  Commands:

    help [<type>:]<prop> Opens help info at MDC for <prop> in
                         your default browser. Optionally
                         searches other resources of <type>:
                         safari opera w3c ms caniuse quirksmode

  Options:

    -i, --interactive       Start interactive REPL
    -u, --use <path>        Utilize the stylus plugin at <path>
    -U, --inline            Utilize image inlining via data uri support
    -w, --watch             Watch file(s) for changes and re-compile
    -o, --out <dir>         Output to <dir> when passing files
    -C, --css <src> [dest]  Convert css input to stylus
    -I, --include <path>    Add <path> to lookup paths
    -c, --compress          Compress css output
    -d, --compare           Display input along with output
    -f, --firebug           Emits debug infos in the generated css that
                            can be used by the FireStylus Firebug plugin
    -l, --line-numbers      Emits comments in the generated css
                            indicating the corresponding stylus line
    --include-css           Include regular css on @import
    -V, --version           Display the version of stylus
    -h, --help              Display help information
like image 21
TheHippo Avatar answered Oct 27 '22 04:10

TheHippo