Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto reload scss? #339

Open
Ramblurr opened this issue Dec 27, 2017 · 8 comments
Open

Auto reload scss? #339

Ramblurr opened this issue Dec 27, 2017 · 8 comments

Comments

@Ramblurr
Copy link

Using the +scss option (without cljs/figwheel) how can I auto reload the scss? Currently I have to run lein sassc once everytime I make a change.

@yogthos
Copy link
Member

yogthos commented Dec 27, 2017

You could use lein-auto plugin to watch for changes and run sassc automatically.

@Ramblurr
Copy link
Author

Thanks @yogthos , I see the luminus template already included a config for lein auto. However it doesn't work as it stands now:

   :auto
   {"sassc"
    {:file-pattern #"\.(scss|sass)$" :paths ["resources/scss"]}}

This doesn't work because the task to run to generate the css is sassc once not sassc. Changing the "sassc" bit to "sassc once" then running lein auto sassc once doesn't re-gen on file changes. Not sure if this is a bug in lein auto or not.

@yogthos
Copy link
Member

yogthos commented Dec 28, 2017

Looking through the source in auto, it does look like it passes the args to the task here. Might be worth opening an issue to ask though. Another option could be to create an alias, something like:

:aliases {"auto-sassc" ["sassc" "once"]}

There's also another plugin called lein-watch that has an example of this functionality in the example project.

@yogthos
Copy link
Member

yogthos commented Dec 28, 2017

So I ended up making a few updates to lein-watch here, if you could try it to see whether it works for you that would be great: [yogthos/lein-watch "0.0.4"].

@yogthos
Copy link
Member

yogthos commented Dec 28, 2017

Here's the project setup I tested with:

:plugins [[lein-cprop "1.0.3"]
            [lein-immutant "2.1.0"]
            [lein-sassc "0.10.4"]
            [yogthos/lein-watch "0.0.4"]]

   :sassc
   [{:src "resources/scss/screen.scss"
     :output-to "resources/public/css/screen.css"
     :style "nested"
     :import-path "resources/scss"}]

  :watch
  {:rate 150
   :color :blue
   :watchers {:sassc {:watch-dirs ["resources/scss"]
                      :file-patterns [#"\.(scss|sass)$"]
                      :tasks ["sassc once"]}}}

@yogthos
Copy link
Member

yogthos commented Dec 29, 2017

Also as a note, I can't reproduce the lein auto problem locally. I ran:

lein auto sassc once
auto> Files changed: resources/scss/screen.scss
auto> Running: lein sassc once
Compile SASS/SCSS files.
sassc -t nested -I resources/scss resources/scss/screen.scss resources/public/css/screen.css

auto> Completed.
auto> Files changed: resources/scss/screen.scss

then changed the file and saw lein auto run again in response:

auto> Running: lein sassc once
Compile SASS/SCSS files.
sassc -t nested -I resources/scss resources/scss/screen.scss resources/public/css/screen.css

auto> Completed.

@Ramblurr
Copy link
Author

@yogthos Using the lein-watch config you posted works great!

I can reproduce the bug/behavior with lein auto just by creating a new luminus project and running lein auto :\

@yogthos
Copy link
Member

yogthos commented Dec 30, 2017

Thanks for the heads up, I might take a look at switching the template to use lein-watch instead then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants