Skip to content

Commit

Permalink
feat: suport scss
Browse files Browse the repository at this point in the history
  • Loading branch information
CCherry07 committed Apr 21, 2024
1 parent a250e63 commit 9b625a5
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/create-farm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ async function copyTemplate(targetDir: string, options: IResultType) {
const template = fs.readFileSync(filepath, 'utf-8');
const dest = filepath.replace(/\.ejs$/, '');
const content = ejs.render(template, dataStore[dest]);

fs.writeFileSync(dest, content);
fs.unlinkSync(filepath);
}
}
);
// ts handle
if (needsTypeScript !== false) {
preOrderDirectoryTraverse(
root,
Expand Down Expand Up @@ -352,6 +352,29 @@ async function copyTemplate(targetDir: string, options: IResultType) {
}
);
}
// css handle
if (useCssPreProcessor !== 'none') {
preOrderDirectoryTraverse(
root,
() => {},

Check failure on line 359 in packages/create-farm/index.ts

View workflow job for this annotation

GitHub Actions / TS Code Lint

Unexpected empty arrow function
(filepath) => {
if (filepath.endsWith('.css')) {
let cssFileExt = 'css';
if (useCssPreProcessor.endsWith('sass')) {
cssFileExt = 'scss';
} else if (useCssPreProcessor.endsWith('less')) {
cssFileExt = 'less';
}
const tsFilePath = filepath.replace(/\.css$/, `.${cssFileExt}`);
if (fs.existsSync(tsFilePath)) {
fs.unlinkSync(filepath);
} else {
fs.renameSync(filepath, tsFilePath);
}
}
}
);
}
// copy(templatePath, dest);
writePackageJson(dest, options);
spinner.text = colors.white(language.copy.done);
Expand Down

0 comments on commit 9b625a5

Please sign in to comment.