Best way to auto compile compass-style SASS via maven

前端 未结 4 1185
挽巷
挽巷 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: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

提交回复
热议问题