let BuildCache = require('@ndcode/build_cache')
let disk_build = require('@ndcode/disk_build')
let fs = require('fs')
-let less = require('less')
+let sass = require('sass')
let path = require('path')
let util = require('util')
let fs_readFile = util.promisify(fs.readFile)
let fs_writeFile = util.promisify(fs.writeFile)
-let LessCSSCache = function(root, diag1, diag) {
- if (!this instanceof LessCSSCache)
- throw new Error('LessCSSCache is a constructor')
+let SassCSSCache = function(root, diag1, diag) {
+ if (!this instanceof SassCSSCache)
+ throw new Error('SassCSSCache is a constructor')
BuildCache.call(this, diag)
this.diag1 = diag1
this.root = root || '.'
}
-LessCSSCache.prototype = Object.create(BuildCache.prototype)
+SassCSSCache.prototype = Object.create(BuildCache.prototype)
-LessCSSCache.prototype.build = async function(key, result) {
+SassCSSCache.prototype.build = async function(key, result) {
let render = await disk_build(
key,
async temp_pathname => {
- let render = await less.render(
- await fs_readFile(key, {encoding: 'utf-8'}),
- {
- compress: true,
- filename: key,
- pathnames: [path.posix.dirname(key)],
- rootkey: this.root
- }
+ let render = await sass.compileAsync(
+ key,
+ {loadPaths: [path.posix.dirname(key)]}
)
await fs_writeFile(
temp_pathname,
render.css,
{encoding: 'utf-8'}
)
- return render.imports
+ return render.loadedUrls
},
this.diag1
)
result.value = await fs_readFile(render.pathname)
}
-module.exports = LessCSSCache
+module.exports = SassCSSCache
{
- "name": "@ndcode/less_css_cache",
+ "name": "@ndcode/sass_css_cache",
"version": "0.1.0",
- "description": "Less CSS compiler, caching front-end with live recompilation",
+ "description": "Sass CSS compiler, caching front-end with live recompilation",
"keywords": [
- "Less",
+ "Sass",
"CSS",
"server-side",
"render",
"license": "MIT",
"repository": {
"type": "git",
- "url": "https://git.ndcode.org/public/less_css_cache.git"
+ "url": "https://git.ndcode.org/public/sass_css_cache.git"
},
"bugs": {
"email": "nick@ndcode.org"
},
- "main": "LessCSSCache.js",
+ "main": "SassCSSCache.js",
"engines": {
"node": ">=0.4.0"
},
"dependencies": {
"@ndcode/build_cache": "^0.1.0",
"@ndcode/disk_build": "^0.1.1",
- "less": "^3.8.1"
- },
- "devDependencies": {}
+ "sass": "^1.47.0"
+ }
}