Comments (21)
Why not just using entr to watch and reload?
from sassc.
Here's another way I documented that you can use using fswatch π
from sassc.
I know I'm a little late to the party, but I found a workaround that works just fine for me as long as I just work on one scss / css files pair: Have the sassc input.scss output.css --style=...
bash command repeat itself as described in this accepted stackoverflow answer.
In short: Bash (and probably other terminal flavors as well) provides a built-in "watch" function with a pretty straight forward syntax watch -n 30 sassc input.scss output.css --style=...
for a 30 seconds repition.
I thought I'd add this here since 1) I haven't been aware of @fgimian 's exquisite solution π₯ to date and 2) there's no need to even installing any additional tools.
Edit: Of course there's still the need for a browser tab reload, I solved this with one of dozens of addons available out there.
from sassc.
So, I tried some of the above solutions, but this seems to be the simplest one that works for me so I thought I'd share.
I made a simple shell script using a inotifywait with a while do loop.
#!/bin/bash
while inotifywait -r -e close_write sass; do
sassc --style compact ./sass/style.scss ./style.css
done
You have to install inotify-tools if you haven't yet.
The -r flag means recursive because I'm using a ./sass/ directory with partials in sub-directories. The -e is the event-type flag. You may need to experiment with what exact event types your editor triggers when saving, there are often multiple opens / reads, but the 'close_write' event only triggered once per save for my editor (Atom) so that's the one that I used to trigger the sassc command. You can review the man page here: https://linux.die.net/man/1/inotifywait
My file structure is almost always something like the following (simplified). You can edit the script according to yours.
βββ style.css
βββ sass
Β Β βββ style.scss
Β Β βββ elements
Β Β Β Β βββ _elements.scss
Β Β Β Β βββ _lists.scss
Β Β Β Β βββ _tables.scss
I put the script in my local path of /.local/bin/sasswatch so all I have to do is navigate to the appropriate directory and then type sasswatch
Don't forget to set execute permissions for the script with chmod 755 sasswatch
I'm running Linux Pop!_OS (Ubuntu).
from sassc.
No, we haven't built this yet. You could make it work with something like guard. But, this is definitely something we should build in.
from sassc.
I think this will be pretty hard to implement portable! sassc
currently is pretty C standard compliant. We only need some additional code on windows to parse the input arguments (getopt
). File watching is unfortunately not part of posix and pretty much implemented differentely on every system. This should be somewhat obvious, since it basically involves an event which is triggered by the filesystem. With a fallback solution to checking every monitored file/directory in an interval (bad). I've done it with perl, but it was still a big pain, due to different implementations. Just read the decription for Filesys::Notify::Simple
:
"A simple but unified interface to get notifications of changes to a given filesystem path. It utilizes inotify2 on Linux, fsevents on OS X, kqueue on FreeBSD and FindFirstChangeNotification on Windows if they're installed, with a fallback to the full directory scan if they're not available."
Unitil someone knows a C library that abstracts all these portability problems for *nix/mac/win, I don't think this is feasible, so I'm in favor of closing this issue. Seems to be a perfect candidate for other implementations to step in!
from sassc.
I think even if you can just watch one file, using some kind of polling technique, it would be useful. (The lack of this is the primary reason I'm going back to using the Ruby gem.)
from sassc.
So, this exists:
https://code.google.com/p/simplefilewatcher/
from sassc.
@chriseppstein simplefilewatcher looks promising from a glance.
As an alternative for the moment I've just supercharged the watcher in node-sass. It's now aware of the @import
dependency graph and will only compile the ancestors (much like the current Ruby sass watcher).
from sassc.
Whats the status of this issue ? Will it be implemented or should this be closed ?
from sassc.
Noone is currently working on this. Our priority right now is getting Ruby Sass parity.
If you're using node/io.js node-sass currently has a great watcher. There are also binding for perl, ruby, python, and go.
from sassc.
We made something that builds on sassc to provide directory compilation and watching: http://github.com/dailymuse/gosass
Hope that helps π
from sassc.
There no plans to implement this in the near future. Pull requests are welcome.
from sassc.
+1 Using Node-Sass + Chokidar for now, but would prefer --watch
in SassC.
from sassc.
What could possibly be done portably is an interface to external file watcher that just feeds the file names via the standard input to libsass.
from sassc.
+1 for me too π
from sassc.
+1
from sassc.
+1
from sassc.
Thanks @fgimian that's neat.
I just added -i ".*\.scss$" -e ".*"
to the fswatch
options to only watch for scss file changes.
from sassc.
Ah nice @ziodave, glad you found it handy π
from sassc.
Would love to have this now that sass-ruby is nearing end of life.
from sassc.
Related Issues (20)
- unrecognized command line option '-stdlib=libc++'
- `--version` is broken HOT 4
- SASS_PATH is ignored HOT 3
- sass_make_data_context adopts char* HOT 5
- Building jekyll site fails HOT 2
- On Windows search for libsass.so instead of libsass.dll HOT 3
- error compiling sassc on aarch64 HOT 1
- With rails 6 Failure/Error: @import "fancy-buttons"
- globbed imports? HOT 1
- New sassc 3.6.1 is broken HOT 1
- installing sassc from snap HOT 1
- Option to add contentSources to source map
- "Installing sassc 2.4.0 with native extensions" takes a long time HOT 4
- Mark SassC as deprecated
- Ship precompiled gems for Linux HOT 2
- Allow for more complex at-media query HOT 2
- makefile not working HOT 1
- Bad value (βtigerlakeβ) for β-march=β
- There is one vulnerability that will lead to an endless loop HOT 1
- Could not execute command 'sasscβ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sassc.