MCPcopy Create free account
hub / github.com/6pac/SlickGrid / buildSassFile

Function buildSassFile

scripts/builds.mjs:194–224  ·  view source on GitHub ↗
(sassFile)

Source from the content-addressed store, hash-verified

192 * @param {String} sassFile
193 */
194export async function buildSassFile(sassFile) {
195 let sassLogged = false;
196 const filename = path.basename(sassFile, '.scss');
197 // const extension = path.extname(sassFile);
198
199 if (!sassLogged) {
200 console.log(`[${styleText('magenta', 'SASS')}] SASS file changes detected`);
201 sassLogged = true;
202 }
203 if (filename.startsWith('_')) {
204 // when _variables changes, let's rebuild all SASS files instead of just one
205 console.log(`[${styleText('magenta', 'SASS')}] scss variable file changed, requires full SASS rebuild (triggered by`, `"${sassFile}")`);
206 await buildAllSassFiles();
207 } else {
208 const srcDir = 'src';
209 const distDir = 'dist';
210 const basePath = path.join(process.cwd(), `/${srcDir}/styles`);
211 const absoluteFilePath = path.relative(basePath, sassFile);
212 const posixPath = absoluteFilePath.replaceAll('\\', '/');
213
214 try {
215 outputFileSync(
216 `${distDir ? distDir + '/' : ''}styles/css/${filename}.css`,
217 sassCompile(`${srcDir ? srcDir + '/' : ''}styles/${posixPath}`, { style: 'compressed', quietDeps: true, noSourceMap: true }).css
218 );
219 } catch (err) {
220 // don't do anything when an error occured, this is to avoid watch mode to crash on errors
221 console.error('SASS error: ', err);
222 }
223 }
224}

Callers 1

executeCommandCallbackFunction · 0.90

Calls 2

outputFileSyncFunction · 0.90
buildAllSassFilesFunction · 0.85

Tested by

no test coverage detected