Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sass --watch not recompiling

Tags:

css

sass

ruby

watch

Sass updates my main stylesheet build.css when I save changes to build.scss, but will not update build.css when I save changes to any partials, for example _grid-settings.scss. I essentially have to manually re-save build.scss each time I make a change to a partial in order for Sass to detect a change.

From my terminal:

Justins-MacBook-Air:ageneralist justinbrown$ sass --watch stylesheets:stylesheets
>>> Sass is watching for changes. Press Ctrl-C to stop.
  write stylesheets/build.css
[Listen warning]:
  Listen will be polling for changes. Learn more at https://github.com/guard/listen#polling-fallback.

My directory is:

stylesheets/
├── base
│   └── _base.scss
├── build.css
├── build.scss
├── layout
│   └── _layout.scss
└── vendor
    ├── _grid-settings.scss
    ├── bourbon
    ├── highlight
    └── neat

I'm using:

  • Sass 3.3.8.
  • Ruby 2.0.0-p353
  • OSX 10.9

I've looked through several SO posts on issues with sass --watch but none have helped yet to guide me to a solution.

EDIT: I'm adding my build.scss here just in case that's the issue:

@import "vendor/bourbon/bourbon";
@import "vendor/grid-settings";
@import "vendor/neat/neat";
@import "base/base";
@import "layout/layout";
like image 942
JustinTBrown Avatar asked Jun 13 '14 10:06

JustinTBrown


People also ask

How many syntaxes that Sass support?

Sass consists of two syntaxes.

What does Sass watch mean?

The watch flag tells Sass to watch your source files for changes, and re-compile CSS each time you save your Sass. If you wanted to watch (instead of manually build) your input.scss file, you'd just add the watch flag to your command, like so: sass --watch input.scss output.css.


2 Answers

I had the same issue.

I managed to fix it by deleting the SASS cache directory. I also ran sudo gem update to update all gems on my system.

I'm not sure which of these things fixed it or if it was a combination of the two.

like image 107
Antfish Avatar answered Feb 05 '23 19:02

Antfish


I had also stuck to the problem of Sass seemed wasn`t watching all file changes correctly.

Sass can`t watch changes in files that are located by the path directing upwards the watching file. For example:

Variant A (Which I had)

scss/
├── base
│   └── controller1.scss
├── utils
│   └── utils.scss
└── app
    └── app.scss

Where app.scss is:

@import '../base/container1'
@import '../utils/utils'

compiling

sass --watch app/app.scss:../css/styles.css

sass --watch app:../css

In both cases sass tracks only app.scss file changes, but not controller1.scss or utils.scss

Variant B (solution)

scss/
├── base
│   └── controller1.scss
├── utils
│   └── utils.scss
└── app.scss

Where app.scss:

@import 'base/container1'
@import 'utils/utils'

compiling

sass --watch app.scss:../css/styles.css

Variant C (solution) also works

scss/
├── base
│   └── controller1.scss
├── utils
│   └── utils.scss
└── app.scss

Where app.scss:

@import 'base/container1'

and controller1.scss:

@import '../utils/utils'
// ...
like image 27
Andrii Bogachenko Avatar answered Feb 05 '23 20:02

Andrii Bogachenko