Using Maven SmartSprites With Sass

I'm using SmartSprites with SCSS.

SmartSprites requires that Sprite Reference Directives must look like so:

background-image:url('image.png'); /** sprite-ref: mysprite; */

In other words, I need comments at the end of my background-image declarations in my compiled CSS file, but none of the four output_styles of Sass allow this to happen. After compiling:

:nested or :expanded

background-image:url('image.png');
/** sprite-ref: mysprite; */

:compact

.selector { background-image:url('image.png'); /** sprite-ref: mysprite; */ }

:compressed

.selector{background-image:url('image.png');}

Under any of these settings, running Maven to generate the sprite with SmartSprites reports a build failure.

The solution must...

  • adhere to SmartSprite's formatting requirements (i.e. have comments at the end of the same line)
  • work automatically (no manual action required for formatting)
  • not be specific to any single text-editor
  • not abandon SCSS (because cavemen do otherwise)

Answers


Use the maven-replacer-plugin to format the stylesheet during the Maven build process.

In pom.xml, insert the following inside maven-replacer-plugin's <executions>:

<execution>
    <id>smartsprite-formatting</id>
    <phase>process-sources</phase>
    <goals>
        <goal>replace</goal>
    </goals>
    <configuration>
        <basedir>src/main/my-project</basedir>
        <includes>
            <include>**/*.css</include>
        </includes>
        <replacements>
            <replacement>
                <token>;\s*?\n.*/\*\*</token>
                <value>; /\*\*</value>
            </replacement>
        </replacements>
    </configuration>
</execution>

Ensure that the filepath in <basedir> is correct and the <phase> is set to a phase in the Maven Lifecycle that occurs before SmartSprites is run. process-sources is pretty ideal, so it may not have to be changed.


Need Your Help

Default linkage model in gcc 4.4 vs. gcc >4.4

c++ namespaces g++ linkage

I'm trying to use two large, complex linear algebra libraries which define many of the same functions. I can't rewrite (legally in one case, but technically in both) either of them. Let's call them "

Spring Security SAML - how to configure client auth?

java spring spring-security saml spring-saml

I'm trying to adapt the Spring Security SAML sample application to use a test IDP (provided to me by someone else) instead of ssocircle. Clicking on the "SAML Login" correctly redirects me to the SSO