1

How would I add a context menu item when right-clicking a .scss file to get SASS to watch it?

Example CLI command:

sass --watch MySassStyle.scss --style compressed

The above command is used after changing the directory to where the .scss file is. Where 'MySassStyle.scss' is any .scss file selected.

So the context menu item would change the directory to where the selected .scss is located, then run the sass command on the file (regardless of filename).


Update: Discovered the wonderful Sublime Text 2 code editor and a package on Github that includes a nice built-in build script: https://github.com/n00ge/sublime-text-haml-sass

Now I can hit Ctrl+B to watch the file directly from Sublime Text 2.


Update 2: I thought I'd share my answer to my question for those not using Sublime Text 2. By using the code from the batch file found in the Github package above it's quite easy to do this.

  1. Open Notepad, paste in the following code, then save the file as "SASSWatch.bat" (with the quote marks):

    cd /d %1
    sass --watch .:. --style compressed
    pause
    

    Note: remove --style compressed to output to a non-compressed .css file, or add other options like --no-cache to disable the cache folder.

  2. Open the Run box (Win+R) and enter control folders. This opens the Folder Options settings.

  3. Click on the File Types tab and scroll down to the SCSS filetype (if it doesn't exist click the 'New' button instead and manually add the SCSS extension).
    Once selected click the 'Advanced' button then click the 'New...' button to add a new Action.
    Name the Action 'Watch' and paste in the following code into the 'Application used to perform action' box (with the quote marks, change the path to where the batch file is located):

    "C:\Documents and Settings\Username\Desktop\SASSWatch.bat" "%1"
    
  4. Click 'OK' on all the windows are you're done! Now right-click any .scss file and select 'Watch' to watch the file using SASS.

0

You must log in to answer this question.

Browse other questions tagged .