다음은 유용한 항목입니다. 프로젝트 폴더에 개의 부분이 (예 : _file1.scss, _file2.scss 등) 인 것으로 나타났습니다. 그 중 일부는 가져 오지 않아서 하나 이상의 파일을 가져야합니다.
const gulp = require('gulp');
const fs = require('fs');
const path = require('path');
const filter = require('gulp-filter');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const addsrc = require('gulp-add-src');
// const glob = require("glob");
const sources = ['project1', 'project2', 'project3'];
// could glob your sourceFolders with something like
// const sources = glob.sync("project*");
const filterSources = Object.keys(sources);
function isUnique(file, index) {
console.log(path.basename(file.path)); // file1.scss, file2.scss, etc. all from project1
baseName = path.basename(file.path);
folder = sources[index]; // project
// does that basename exist in thecurrent project (sources[index])
return !fs.existsSync(folder + path.sep + baseName);
}
gulp.task('default', function() {
// loop through all the project folders
filterSources.forEach(function (project, index) {
const f = filter(function (file) {
return isUnique(file, index);
});
// always using project1 files as basis
const stream = gulp.src('./project1/*.scss')
// filter out from the source stream (project1 files) any files that appear in the current project directory
.pipe(f)
// add all files from the current project directory, i.e., project2, project3, etc.
.pipe(addsrc.append('./' + sources[index] + '/*.scss'))
.pipe(sass().on('error', sass.logError))
// give the concat the filename of the current project
.pipe(concat(sources[index] + '.css'))
.pipe(gulp.dest('css'));
return stream;
});
이것은 단지 다른 수입이 아닌 부분하는 SCS 파일 필터링 하나가 아닌지 확인, 프로젝트 폴더의 번호를 사용할 수 있습니다.
concat 각 프로젝트마다 모든 파일이 있으므로 각 파일 이름에서 앞에 오는 밑줄을 제거해야하기 때문에 어쨌든 일부 부분을 원하지 않는 것처럼 보입니다.
감사합니다. 당신은 확실히 나를 올바른 방향으로 밀어 넣었습니다. 귀하는 부분적인 부분에 대해 어느 정도 권리가 있습니다. 그것이 magento 프로젝트이기 때문에 시스템은 무엇을 포함하고 무엇을 포함하지 않을지 신경 쓸 수 있습니다. 불행히도 나는 기초 프로젝트에서 일하려고 애를 쓰고 있으며 partial을 사용하지 않는 것이 불가능한 것처럼 보인다. 나는 sass 레벨 (@import)에서이 상속을 할 수 있었으면 좋겠다. –