/
build.js
32 lines (24 loc) · 911 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { compile } from 'sass';
import pkg from 'fs-extra';
import path from 'path';
const { ensureDirSync, writeFileSync, copySync } = pkg;
const cssOutputPath = path.resolve(__dirname, 'dist/assets/css');
function compileSassFiles() {
const sassFiles = ['src/assets/**/*.scss'];
sassFiles.forEach(file => {
const result = compile({ file });
const outputFilePath = path.resolve(__dirname, file.replace('src/assets', cssOutputPath).replace('.scss', '.css'));
ensureDirSync(path.dirname(outputFilePath));
writeFileSync(outputFilePath, result.css);
});
}
function copySassFiles() {
const sassFiles = ['src/assets/**/*.scss'];
sassFiles.forEach(file => {
const outputFilePath = path.resolve(__dirname, file.replace('src/assets', cssOutputPath));
ensureDirSync(path.dirname(outputFilePath));
copySync(file, outputFilePath);
});
}
compileSassFiles();
copySassFiles();