feat: ✨ optimize css sizes
This commit is contained in:
@@ -5,7 +5,6 @@ import { compile } from 'sass';
|
||||
|
||||
const logger = new Logger(buildScss.name, 'debug', 'pink');
|
||||
const themesSrc = 'themes/scss';
|
||||
const baseStylesSrc = 'styles';
|
||||
const cssDistPath = '/public/assets/css';
|
||||
|
||||
async function buildThemes(srcPath, distPath) {
|
||||
@@ -34,40 +33,12 @@ async function buildThemes(srcPath, distPath) {
|
||||
}
|
||||
}
|
||||
|
||||
async function buildBaseStyle(srcPath, distPath) {
|
||||
const scssFiles = getScssFiles(srcPath, baseStylesSrc);
|
||||
|
||||
for (const file of scssFiles) {
|
||||
logger.debug(`Building ${scssFiles.name} file`);
|
||||
|
||||
const result = compile(file.path, {
|
||||
loadPaths: [join(srcPath, '../node_modules')],
|
||||
quietDeps: true,
|
||||
logger: {
|
||||
debug: logger.simpleDebug.bind(logger),
|
||||
info: logger.simpleInfo.bind(logger),
|
||||
warn: logger.simpleWarn.bind(logger),
|
||||
error: logger.simpleError.bind(logger),
|
||||
}
|
||||
});
|
||||
|
||||
logger.debug(`Writing ${file.name} css file to disk`);
|
||||
|
||||
writeFileSync(
|
||||
join(distPath, cssDistPath, `${file.name}.css`),
|
||||
result.css
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildScss(srcPath, distPath) {
|
||||
logger.info('SCSS build has started');
|
||||
|
||||
mkdirSync(join(distPath, cssDistPath), { recursive: true });
|
||||
|
||||
await buildBaseStyle(srcPath, distPath);
|
||||
await buildThemes(srcPath, distPath);
|
||||
|
||||
logger.info('SCSS build has finished');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user