Best way to auto compile compass-style SASS via maven

前端 未结 4 1114
挽巷
挽巷 2021-02-08 10:35

referring to SASS implementation for Java? :

What is the best way to auto-compile compass-style.org stylesheets in maven goal compile respectively package?

I wou

相关标签:
4条回答
  • 2021-02-08 11:14

    I suppose you know about this Maven plugin (mentioned in SASS implementation for Java?)? : https://github.com/Jasig/sass-maven-plugin

    (I haven't tried it myself yet.)

    UPDATE: that plugin is no longer supported. However, this fork seems to be healthy at present, so it might be an option for some: https://github.com/GeoDienstenCentrum/sass-maven-plugin

    0 讨论(0)
  • 2021-02-08 11:15

    I tried several ways to compile my app (java, Wicket, using Zurb Foundation Sites, node-sass with depebndency of lib-sass). To tell you the truth, all the maven plugins were somewhere a deadend, especially when my scss contained the !global flag. (This flag came with foundations.) So the final solution for us was to build with npm first then use maven. Npm builds into src/main/webapp/"myDir" dir. I excluded this dir in git. The jason file has a line like:

    "scripts": {
        ....
        "build-css": "node node_modules/node-sass/bin/node-sass --include-path myScssDir myScssDir/myScss.scss --output  src/main/webapp/myDir/css",
        ....
    }
    

    Then build with maven and it will move the builded css ino my war. For some help (create the nonexisting "myDir" dir) i used mkdirp. In my jason there is:

    "scripts": {
        "create-dirs": "mkdirp src/main/webapp/myDir/",
        ....
    }
    

    So i run "npm i" to install all my dependencies locally into node-modules dir. This is gitignored.

    Then i run "npm run create-dirs" to create the necessary myDir. This is gitignored as well.

    Then i run "npm run build-css" to compile my css-s and js-s into myDir.

    Finally i make a maven build.

    With a hudson/jenkins build, you can easily do these in one job.

    One improvement i can think of is to run npm via ant during maven build. I'll get back to you when i have a proof of concept of this.

    //One extra hint: if you are developing under corporate environment and Windows7 you may have to add permissions to symbolic links for npm build. If you find errors in npm build, it worth a try: https://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7

    0 讨论(0)
  • 2021-02-08 11:15

    I was using the Sass Maven Plugin by nl.geodienstencentrum.maven but it uses Ruby and is very slow.

    I've now switched to: Libsass Maven Plugin

    https://github.com/warmuuh/libsass-maven-plugin

    This uses C and our compile times are much less (8.6 seconds to -> 2 seconds)

    0 讨论(0)
  • 2021-02-08 11:34

    I found this, it's not a special compass/sass plugin but it works

    https://gist.github.com/1671207

    0 讨论(0)
提交回复
热议问题