5 Star 1 Fork 0

Gitee 极速下载/october

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/octobercms/october
克隆/下载
webpack.helpers.js 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
Sam Georges 提交于 2022-09-28 10:05 . Update developer tools
/*
|--------------------------------------------------------------------------
| Mix Extensions
|--------------------------------------------------------------------------
|
| Adds custom helper functions to the mix object.
|
*/
const { lstatSync, readdirSync } = require('fs');
const { join } = require('path');
const fs = require('fs');
const isDirectory = (source) => lstatSync(source).isDirectory();
const getDirectories = (source) => readdirSync(source).map((name) => join(source, name)).filter(isDirectory);
function makeComponentLessList(source) {
const componentDirs = getDirectories(source);
const result = [];
componentDirs.forEach((dir) => {
const parts = dir.replace(/\\/g, '/').split('/');
const componentName = parts[parts.length - 1];
const lessFile = dir + '/assets/less/' + componentName + '.less';
if (fs.existsSync(lessFile)) {
result.push(componentName);
}
});
return result;
}
// Attach the helpers to the mix object
module.exports = (mix) => {
// Wildcard helper for components
mix.lessList = (path, except = []) => {
makeComponentLessList(path)
.filter(name => !except.includes(name))
.forEach(name => mix.less(`${path}/${name}/assets/less/${name}.less`, `${path}/${name}/assets/css/`))
;
};
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/october.git
git@gitee.com:mirrors/october.git
mirrors
october
october
3.x

搜索帮助