Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from node-sass to sass #1215

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions assets/trix/stylesheets/functions.js

This file was deleted.

41 changes: 41 additions & 0 deletions bin/sass-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env node

const path = require("path")
const fs = require("fs")
const sass = require("sass")
const { optimize } = require("svgo")

const args = process.argv.slice(2)
if (args.length < 2) {
console.error("Usage: bin/sass-build <inputFile> <outputFile>")
process.exit(1)
}
const inputFile = path.resolve(args[0])
const outputFile = path.resolve(args[1])

const basePath = path.dirname(inputFile)

const functions = {
"svg($file)": (svgFileName) => {
const filename = path.resolve(basePath, svgFileName.getValue())

let svgContent = fs.readFileSync(filename, "utf8")
svgContent = optimize(svgContent, { multipass: true, datauri: "enc" })

return new sass.SassString(`url("${svgContent.data}")`, { quotes: false })
},
}

sass.render(
{
file: inputFile,
functions
},
(err, result) => {
if (err) {
console.error("Error compiling SCSS:", err)
} else {
fs.writeFileSync(outputFile, result.css, "utf8")
}
}
)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
"karma-chrome-launcher": "3.2.0",
"karma-qunit": "^4.1.2",
"karma-sauce-launcher": "^4.3.6",
"node-sass": "^7.0.1",
"qunit": "2.19.1",
"rangy": "^1.3.0",
"rollup": "^2.56.3",
"rollup-plugin-includepaths": "^0.2.4",
"rollup-plugin-terser": "^7.0.2",
"sass": "^1.83.0",
"svgo": "^2.8.0",
"webdriverio": "^7.19.5"
},
"resolutions": {
"webdriverio": "^7.19.5"
},
"scripts": {
"build-css": "node-sass --functions=./assets/trix/stylesheets/functions assets/trix.scss dist/trix.css",
"build-css": "bin/sass-build assets/trix.scss dist/trix.css",
"build-js": "rollup -c",
"build-assets": "cp -f assets/*.html dist/",
"build": "yarn run build-js && yarn run build-css && yarn run build-assets",
Expand Down
Loading
Loading