Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SASS implementation for Java? [closed]

I'm looking for SASS implementation in Java (could be used with JSP/JSF). For Python I've found CleverCSS, but there is nothing for Java. Anyone heard something about this sort of tool for generating CSS?

like image 273
user213225 Avatar asked Nov 17 '09 20:11

user213225


People also ask

Do I need to install Sass for every project?

You'll never need to install Sass again! Npm is a command line interface that comes bundled with the server framework, node. js.

Does Sass need to be compiled?

Once you start tinkering with Sass, it will take your preprocessed Sass file and save it as a normal CSS file that you can use in your website. The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS using the sass command.

How do I stop Sass compiling?

Usage/Shortcuts. Click to Watch Sass from the status bar to turn on the live compilation and then click to Stop Watching Sass from the status bar to turn off live compilation.


1 Answers

With ANT:

  1. Download JRuby complete jar file (JRuby Complete jar download page)
  2. Download the latest HAML/SASS code (HAML/SASS tarball), and extract it. Put it in "/libs/sass-[VERSION]"
  3. Add the following to an ant build file.
  4. Replace [VERSION] in the script to the corresponding versions of JRuby and SASS
  5. Run the ant script, and the sass or scss files will be compiled!

<path id="JRuby">     <fileset file="libs/jruby-complete-[VERSION].jar"/> <!-- Location of JRuby jar file --> </path>    <target name="compileSCSS">     <echo message="Compiling scss files..." />     <property name="filesIn" value="${dir.css}/scss/**/[^_]*.scss" />     <property name="fileOutDir" value="/${dir.css}/${dir.css.build}" />     <script language="ruby" classpathref="JRuby">         <![CDATA[             require 'libs/sass-[VERSION]/lib/sass'             require 'sass/exec'              files = Dir.glob($project.getProperty('filesIn'))             Dir.mkdir($project.getProperty('fileOutDir')) unless File.exists?($project.getProperty('fileOutDir'))             files.each do                  | file |                 puts "     [sass compiler] " + file + " -> " + $project.getProperty('fileOutDir') + "/" + File.basename(file, ".*") + ".css"                 opts = Sass::Exec::Sass.new(["--load-path", File.dirname(file), file, File.join($project.getProperty('fileOutDir'), File.basename(file, ".*") + ".css")])                 opts.parse             end         ]]>     </script>     <echo message="Done compiling scss files!" /> </target> 

With MAVEN:

Maven can also do this: Using the antrun plugin:

<project> <build> <plugins> <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-antrun-plugin</artifactId>     <version>1.6</version>     <executions>         <execution>             <id>compileAndMinify</id>             <phase>compile</phase>             <goals>                 <goal>run</goal>             </goals>             <configuration>                 <target>                     <mkdir dir="${project.build.directory}/compiled" />                      <echo message="Compiling scss files..."/>                     <path id="JRuby">                         <fileset file="${basedir}/jars/jruby-complete-[VERSION].jar"/>                     </path>                     <property name="filesIn" value="${project.build.directory}/css/**/[^_]*.scss" />                     <property name="fileOutDir" value="${project.build.directory}/compiled/css" />                     <script language="ruby" classpathref="JRuby">                         <![CDATA[                             require 'libs/sass-[VERSION]/lib/sass'                             require 'sass/exec'                              files = Dir.glob($project.getProperty('filesIn'))                             Dir.mkdir($project.getProperty('fileOutDir')) unless File.exists?($project.getProperty('fileOutDir'))                             files.each do                                  | file |                                 puts "     [sass compiler] " + file + " -> " + $project.getProperty('fileOutDir') + "/" + File.basename(file, ".*") + ".css"                                 opts = Sass::Exec::Sass.new(["--load-path", File.dirname(file), file, File.join($project.getProperty('fileOutDir'), File.basename(file, ".*") + ".css")])                                 opts.parse                             end                         ]]>                     </script>                 </target>             </configuration>         </execution>     </executions> </plugin> </plugins> </build> </project>   
like image 188
Joep Avatar answered Sep 20 '22 03:09

Joep