Created
March 30, 2023 20:15
-
-
Save Slackwise/175fb661c0b02c030c5308400b5fc45a to your computer and use it in GitHub Desktop.
NPM script to compile LESS files because the Visual Studio "Web Compiler" extension doesn't work anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import { exec } from 'child_process'; | |
const compilationConfig = JSON.parse(fs.readFileSync('compilerconfig.json', 'utf8')); | |
compilationConfig | |
.filter(fileConfig => fileConfig.inputFile.endsWith('.less')) | |
.map(({outputFile, inputFile, minify}) => { | |
try { | |
console.log("LESS\tInput:\t" + inputFile); | |
exec(`lessc "${inputFile}" "${outputFile}"`); | |
console.log("\tOutput:\t" + outputFile); | |
if (minify) { | |
const outputMinFile = outputFile.replace('.css', '.min.css'); | |
exec(`lessc --compress "${inputFile}" "${outputMinFile}"`); | |
console.log("\tOutput:\t" + outputMinFile); | |
} | |
} catch (e) { | |
console.log("LESS processing failed:\n" + e.message); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment