File: modules/sass.js

Recommend this page to a friend!
  Classes of Thomas Björk   Node.js Background Jobs   modules/sass.js   Download  
File: modules/sass.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Node.js Background Jobs
Run background jobs using Node.js modules
Author: By
Last change: Added an AutoReloadModule function that automatically reloads a module when it changes.
Added the Unload functions to modules which loads modules of its own.
Date: 3 years ago
Size: 654 bytes
 

Contents

Class file image Download
exports.UExecute = function(parts) { return false; }; exports.TExecute = function(parts, client) { var css, e, nodeSass, s, sass; nodeSass = true; try { s = require.resolve("node-sass"); if (s.length === 0) { nodeSass = false; } } catch(_error) { e = _error; nodeSass = false; } if(nodeSass) { sass = require('node-sass'); css = sass.renderSync({ "data": parts[1] }); client.write(css); client.end(); } else { client.write("404: SASS not available"); client.end(); } }; exports.Unload = function() { var name = require.resolve('node-sass'); delete require.cache[name]; }