Created
November 4, 2024 13:41
-
-
Save rgpublic/2f877644c0ed8c45706382172c7cfa32 to your computer and use it in GitHub Desktop.
LightningCSS Compile
This file contains 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
#!/usr/bin/env node | |
import lightningcss from '/usr/lib/node_modules/lightningcss/node/index.js'; | |
import fs from 'fs/promises'; | |
import * as path from 'path'; | |
const {transform} = lightningcss; | |
if (process.argv.length!=4) { | |
console.log('Usage: compile.js <inputfile> <outputfile>'); | |
process.exit(1); | |
} | |
let infile=process.argv[2]; | |
let outfile=process.argv[3]; | |
const codeBuffer=await fs.readFile(infile); | |
const mapBuffer=await fs.readFile(infile+".map"); | |
let { code, map } = transform({ | |
filename: 'style.css', | |
code: Buffer.from(codeBuffer), | |
inputSourceMap: Buffer.from(mapBuffer), | |
minify: true, | |
sourceMap: true | |
}); | |
await fs.writeFile(outfile,code); | |
await fs.writeFile(outfile+".map",map); |
This file contains 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
{ | |
"type": "module" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment