Skip to content

Instantly share code, notes, and snippets.

@LiYiBin
Last active March 21, 2018 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiYiBin/aac9cba475f3e4ff05bd946fdf51c64c to your computer and use it in GitHub Desktop.
Save LiYiBin/aac9cba475f3e4ff05bd946fdf51c64c to your computer and use it in GitHub Desktop.
// Helpers
const recursiveCompiling = (path, outputPath, funcName, appendedPath = '') => {
const dirPath = `${path}${appendedPath}`;
const filenames = fs.readdirSync(dirPath);
filenames
.filter(filename => !(filename.charAt(0) === '_'))
.filter(filename => !(filename.charAt(0) === '.'))
.forEach(filename => {
const filePath = `${path}${appendedPath}/${filename}`;
const isFile = fs.lstatSync(filePath).isFile();
if (isFile) {
const compilingPath = `${path}${appendedPath}/${filename}`;
const compilingOutputPath = `${outputPath}${appendedPath}`;
mix[funcName](compilingPath, compilingOutputPath);
} else {
const newAppendedPath = `${appendedPath}/${filename}`;
recursiveCompiling(path, outputPath, funcName, newAppendedPath);
}
});
}
// Compiling Sass
const sassPath = 'resources/assets/sass';
const sassOuputPath = 'public/css';
recursiveCompiling(sassPath, sassOuputPath, 'sass');
// Compiling Javascript
const jsPath = 'resources/assets/js';
const jsOuputPath = 'public/js';
recursiveCompiling(jsPath, jsOuputPath, 'js');
// Versioning
mix.version();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment