Best way to auto compile compass-style SASS via maven

Viewed 23890

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 would not like to ship too many self-compiled libraries nor do I want to dynamically ship compiled files via filters like https://code.google.com/p/sass-java ( https://github.com/darrinholst/sass-java )

Any alternatives than hooking up shellscripts / ant scripts which requires installed ruby and compass on the client?

What is the detailed difference between SASS and Compass Stylesheets, any problems with "sass-tools" when regularly using "compass"? => Which mvn plugins are "compass aware"?!

5 Answers

Since libsass-is-deprecated, and the fork bases on the same "archived lib": https://github.com/bit3/jsass ..bases on libsass...

How do I migrate? ... Someone might find this useful:

  1. [choco|brew|npm] install sass
    

    Source: https://sass-lang.com/install (I would not do it in , but we could!)

  2. With the "good ole" exec-maven-plugin, adopted from Spring Petclinic (site|repo) (previously extracting -, originally they used that same libsass-maven-plugin):

    <profile>
      <id>css</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version> 
            <executions>
              <execution>
                <!-- process-resources > genererate-resources (i.e. later)-->
                <phase>process-resources</phase>
              </execution>
            </executions>
            <configuration>
              <!-- must be in $PATH !! -->
              <executable>sass</executable>
              <!-- it is quite silent, when everything works well -->
              <useMavenLogger>true</useMavenLogger>
              <arguments>
                <!-- additional sass path(s), adjust to our suits -->
                <argument>--load-path=${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/</argument>
                <argument>--no-source-map</argument>
                <argument>--verbose</argument>
                <argument>--trace</argument>
                <!-- for more args, see https://stackoverflow.com/a/70228043/592355 // `sass` -->
                <argument>${basedir}/src/main/scss/my.scss</argument>
                <argument>/path/to/my/dest/my.css</argument>
              </arguments>
              <!-- more config, when we like ... -->
            </configuration>
          </plugin>
          <!-- this is not part of the answer, but unpacks us required scss: -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack</id>
                <!-- genererate-resources < process-resources  (i.e. prior)-->
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.webjars.npm</groupId>
                      <artifactId>bootstrap</artifactId>
                      <version>${webjars-bootstrap.version}</version>
                    </artifactItem>
                  </artifactItems>
                  <outputDirectory>${project.build.directory}/webjars</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    
  3. Finally:

    mvn process-resources -Pcss
    

    (assuming no tests, no clean, no compile, "it is quite silent, when everything works well")

Related