refactor: standardize formatting in CSS and JS build configurations
This commit is contained in:
parent
dd0a92b69b
commit
e08549e9d6
2 changed files with 13 additions and 23 deletions
|
|
@ -17,42 +17,32 @@ const buildCss = async (inputPath, outputPaths) => {
|
|||
tailwindcss,
|
||||
autoprefixer,
|
||||
cssnano
|
||||
]).process(inputContent, { from: inputPath });
|
||||
]).process(inputContent, {from: inputPath});
|
||||
|
||||
for (const outputPath of outputPaths) {
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
await fs.mkdir(path.dirname(outputPath), {recursive: true});
|
||||
await fs.writeFile(outputPath, result.css);
|
||||
}
|
||||
|
||||
return result.css;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const buildAllCss = async () => {
|
||||
const tasks = [];
|
||||
|
||||
tasks.push(
|
||||
buildCss(
|
||||
'src/assets/css/global/global.css',
|
||||
['src/_includes/css/global.css']
|
||||
)
|
||||
);
|
||||
tasks.push(buildCss('src/assets/css/global/global.css', ['src/_includes/css/global.css']));
|
||||
|
||||
const localCssFiles = await fg(['src/assets/css/local/*.css']);
|
||||
const localCssFiles = await fg(['src/assets/css/local/**/*.css']);
|
||||
for (const inputPath of localCssFiles) {
|
||||
const baseName = path.basename(inputPath);
|
||||
tasks.push(
|
||||
buildCss(inputPath, [`src/_includes/css/${baseName}`])
|
||||
);
|
||||
tasks.push(buildCss(inputPath, [`src/_includes/css/${baseName}`]));
|
||||
}
|
||||
|
||||
const componentCssFiles = await fg(['src/assets/css/components/*.css']);
|
||||
const componentCssFiles = await fg(['src/assets/css/components/**/*.css']);
|
||||
for (const inputPath of componentCssFiles) {
|
||||
const baseName = path.basename(inputPath);
|
||||
tasks.push(
|
||||
buildCss(inputPath, [`dist/assets/css/components/${baseName}`])
|
||||
);
|
||||
tasks.push(buildCss(inputPath, [`dist/assets/css/components/${baseName}`]));
|
||||
}
|
||||
|
||||
await Promise.all(tasks);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export const buildJs = async (inputPath, outputPath) => {
|
|||
|
||||
const output = result.outputFiles[0].text;
|
||||
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
await fs.mkdir(path.dirname(outputPath), {recursive: true});
|
||||
await fs.writeFile(outputPath, output);
|
||||
|
||||
return output;
|
||||
|
|
@ -23,14 +23,14 @@ export const buildJs = async (inputPath, outputPath) => {
|
|||
export const buildAllJs = async () => {
|
||||
const tasks = [];
|
||||
|
||||
const inlineBundleFiles = await fg(['src/assets/scripts/bundle/*.js']);
|
||||
const inlineBundleFiles = await fg(['src/assets/scripts/bundle/**/*.js']);
|
||||
for (const inputPath of inlineBundleFiles) {
|
||||
const baseName = path.basename(inputPath);
|
||||
const outputPath = `src/_includes/scripts/${baseName}`;
|
||||
tasks.push(buildJs(inputPath, outputPath));
|
||||
}
|
||||
|
||||
const componentFiles = await fg(['src/assets/scripts/components/*.js']);
|
||||
const componentFiles = await fg(['src/assets/scripts/components/**/*.js']);
|
||||
for (const inputPath of componentFiles) {
|
||||
const baseName = path.basename(inputPath);
|
||||
const outputPath = `dist/assets/scripts/components/${baseName}`;
|
||||
|
|
@ -38,4 +38,4 @@ export const buildAllJs = async () => {
|
|||
}
|
||||
|
||||
await Promise.all(tasks);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue