Mitrahsoft
  • SERVICES
    • OUR SERVICES
      • SOFTWARE DEVELOPMENT
      • MOBILE DEVELOPMENT
      • BLOCKCHAIN DEVELOPMENT
      • SOFTWARE TESTING
      • CLOUD & DEVOPS SERVICES
      • PRODUCT DEVELOPMENT
      • OFFSHORE DEVELOPMENT
      • SOCIAL MEDIA MARKETING
      TECHNOLOGIES
      • COLDFUSION DEVELOPMENT
      • REACTJS DEVELOPMENT
      • VUEJS DEVELOPMENT
      • ANGULAR DEVELOPMENT
      • NODEJS DEVELOPMENT
      • PYTHON DEVELOPMENT
      • GOLANG DEVELOPMENT
      • GOLANG CORPORATE TRAINING
      COLDFUSION EXPERTISE
      • MURACMS EXPERTISE
      • COLDFUSION APP MIGRATION
      • COLDFUSION HOSTING & SUPPORT
      • CF LEGACY APP MAINTENANCE
      • COLDFUSION REST API
      • ECOMMERCE / SHOPPING CART SOLUTIONS
      • PRESIDECMS EXPERTISE
      MOBILE DEVELOPMENT
      • REACT NATIVE DEVELOPMENT
      • FLUTTER DEVELOPMENT
      • IONIC DEVELOPMENT
      • PHONEGAP DEVELOPMENT
  • ABOUT US
    • ABOUT MITRAHSOFT
    • OUR CLIENTS
    • TESTIMONIALS
    • PORTFOLIO
    • CAREERS
  • CONTACT US
  • BLOG
Adobe Solution PartnerLucee Solution Partner
Adobe Solution PartnerLucee Solution Partner
Adobe Solution PartnerLucee Solution Partner
  • OUR SERVICESSOFTWARE DEVELOPMENTMOBILE DEVELOPMENTBLOCKCHAIN DEVELOPMENTSOFTWARE TESTINGCLOUD & DEVOPS SERVICESPRODUCT DEVELOPMENTOFFSHORE DEVELOPMENTSOCIAL MEDIA MARKETING
    TECHNOLOGIESCOLDFUSION DEVELOPMENTREACTJS DEVELOPMENTVUEJS DEVELOPMENTANGULAR DEVELOPMENTNODEJS DEVELOPMENTPYTHON DEVELOPMENTGOLANG DEVELOPMENTGOLANG CORPORATE TRAINING
    COLDFUSION EXPERTISEMURACMS EXPERTISECOLDFUSION APP MIGRATIONCOLDFUSION HOSTING & SUPPORTCF LEGACY APP MAINTENANCECOLDFUSION REST API ECOMMERCE / SHOPPING CART SOLUTIONSPRESIDECMS EXPERTISE
    MOBILE DEVELOPMENTREACT NATIVE DEVELOPMENTFLUTTER DEVELOPMENTIONIC DEVELOPMENTPHONEGAP DEVELOPMENT
  • ABOUT MITRAHSOFTOUR CLIENTSTESTIMONIALSPORTFOLIOCAREERS
  • CONTACT US
  • BLOG

Sass Compilation Using Lucee Event Gateway & Jsass JAVA Library

HomeBlogSass Compilation Using Lucee Event Gateway & Jsass JAVA Library
LuceeEvent-gatewaySASS-compilation

Sass Compilation Using Lucee Event Gateway & Jsass JAVA Library

M
Post by MitrahsoftPublished: Dec 20, 2018

Nowadays most of the applications are using SASS instead of CSS, because of its advantages. But it is more important that we need to compile the SASS into CSS. For SASS compilation, there might be lots of native applications & JAVA libraries available.

Both have some advantages & disadvantages like installation required ( in terms of native apps or JS watchers ) or no real-time compilation ( in terms of pure JAVA libraries ).

We all might be satisfied with the above mentioned ways of SASS compilation. But we can now able to do the same compilation with the help of a JAVA library & Event gateways using Lucee.

Requirements:

  • Knowledge to create an event gateway in Lucee
  • Knowledge about using JSass JAVA library

If you've enough knowledge to create an event gateway in Lucee, it is very simple work to make it working as a SASS compiler gateway. For that, you should have the same list of files as we seen in How to create event gateway in Lucee.

Additionally we need to add the below code in listener component's checkChange function. This is the essential part of compiling the sass file into a css file.

sassCompilerListener.cfc

cfml
<cfcomponent>
	<cffunction name="compileSASS" access="public" output="no" returntype="void">
		<cfargument name="data" type="struct" required="yes">
		<cftry>
			<cfset fileCompile(
				arguments.data.directory,
				arguments.data.name,
				replaceNoCase(arguments.data.name, "scss", "css", "ALL")
			)>
			<cfscript>
				for(files in scssDirectory){
					if( !listFindNoCase(".,_", left(files.name, 1)) ){
						if(!directoryExists(replaceNoCase(files.directory, "sass", "css","all"))){
							directoryCreate(replaceNoCase(files.directory, "sass", "css","all"));
						}
					}
				}
			</cfscript>
			<cfcatch type="any">
				<cflog
					text="change:#serialize(data)#"
					type="information"
					file="DirectoryWatcher">
			</cfcatch>
		</cftry>
	</cffunction>
	<cffunction name="fileCompile" access="private" returntype="void">
		<cfargument name="basePath" type="string" required="true">
		<cfargument name="inFileName" type="string" required="true">
		<cfargument name="outFileName" type="string" required="true">
		<cfscript>
			var jars = directoryList(
				arguments.basePath & "/model/java/sassLib",
				false,
				"path",
				"*.jar"
			);
			var compiler = createObject(
				"java",
				"io.bit3.jsass.Compiler",
				jars
			);

			var file = createObject(
				"java",
				"java.io.File",
				jars
			);
			var options = createObject(
				"java",
				"io.bit3.jsass.Options",
				jars
			);
			var inFile = arguments.basePath & "/" & arguments.inFileName;
			var outFile = arguments.basePath & "/" & arguments.outFileName;
			options.setOmitSourceMapUrl(false);
			options.setSourceMapContents(true);
			options.setSourceComments(true);

			options.setSourceMapFile(
				file.init(
					replaceNoCase(outFile, ".css", "") & ".map"
				).toURI()
			);
			var compilerResult = compiler.compileFile(
				file.init(inFile).toURI(),
				file.init(
					replaceNoCase(inFile, ".scss", ".css")
				).toURI(),
				options
			);
			fileWrite(
				outFile,
				compilerResult.getCss()
			);
			fileWrite(
				replaceNoCase(outFile, ".css", "") & ".map",
				compilerResult.getSourceMap()
			);
		</cfscript>
	</cffunction>
</cfcomponent>

As we changed the listener function name & used the JSass java library, we should make the necessary changes like changing the listener CFC path in driver component & place the JSass library in corresponding folders.

Once you've done with creating the new instance for this event gateway, if there is any file change happened in the folder mentioned, the SCSS will be automatically converted into CSS.

Tags

ADYENAMAZON-SESANDROIDAPACHEAPACHE-JMETERAWSBARCODE-SCANNERCOLDBOXCOLDFUSIONCOLDFUSION-API-INTEGRATIONCOLDFUSIONBUILDERECHARTSEVENT-GATEWAYFFMPEGFW1JQUERYJSOUPLUCEEMURACMSMURACMS-THEMENODEJSONESIGNALOSSPAYFLOW-PROPAYMENT-GATEWAYPAYPALPRESIDECMSPUPPETEERRAILORAZUNAREACTJSREACTNATIVERESTSASS-COMPILATIONSEMANTIC-UISUBLIMETEXTTINYMCETWILIOYUI-LIBRARY

Archives

JAN 20DEC 19AUG 19JUL 19JUN 19MAY 19APR 19MAR 19FEB 19JAN 19DEC 18NOV 18OCT 18MAR 16NOV 15SEP 15MAY 15MAY 14OCT 13JUN 13MAY 13APR 13MAR 13FEB 13JAN 13

Follow us

Mitrahsoft
United StatesUnited States

Hurst, Texas, United States

+1 (817) 606-8684usa-sales@mitrahsoft.com

IndiaIndia

Head Office

126G2/5, Thiru malai nagaram,
Kovilpatti - 628 501

Madurai

1/B, 2nd & 3rd floor, GV Complex,

Bye Pass Road, SS Colony,

Madurai - 625 016

Coimbatore

2nd Floor, Sri Narmadha Towers,

Murugan Nagar Rd, Thoppampatti Pirivu,

 K. Vadamadurai, Coimbatore - 641 017

+91 9092480924

business@mitrahsoft.com

ColdFusion
  • eCommerce / Shopping Cart Solutions
  • Payment Gateway Integrations
  • Shipping API Integrations
  • ColdFusion Development Services
  • REST API Development
  • MuraCMS Plugin Creation & Personalization
Technology Services
  • ReactJS Development
  • VueJS Development
  • AngularJS Development
  • NodeJS API Development
  • Python Development
  • Golang Development
  • React Native Development
  • D3.JS data Visualization
Other Services
  • Software Development
  • Mobile Development
  • Blockchain Development
  • Cloud & Devops Services

Connect with MitrahSoft

Please fill out this field
Please fill out this field
Please fill out this field
Please fill out this field
Please fill out this field
Please fill out this field

© 2026 All Rights Reserved. MitrahSoft Solutions Pvt Ltd

Home|About Us|Careers