0

Is it possible to build an css file in dependency to my Theme folder? The problem is i have several themes in there with the same setup gulp should take Theme.scss and build an css file into Theme, Theme1 and so on.

gulp.task('sass', function () {
    return gulp.src('Css/Clients/**/theme.scss') // Gets all files ending with .scss
    .pipe(sass({outputStyle: 'compact'}))
    .pipe(gulp.dest('app/css'))
    .pipe(browserSync.reload({
        stream: true
    }))
});

gulp.task('watch', ['browserSync', 'sass', 'php'], function () {
    gulp.watch('Css/**/*.scss', ['sass']);
})

enter image description here

Edit:

im tryed the solution below the problem i get looks like this :

enter image description here

but i need just the theme.css in theme folder ander theme1.css in theme1 folder and so on! any suggestions ?

 gulp.task('sass', function () {
    var folders = getFolders(scriptsPath);

    var tasks = folders.map(function(folder) {
        return gulp.src(path.join(scriptsPath, folder, '/**/*.scss'))
        .pipe(sass({outputStyle: 'compact'}))
        // concat into foldername.js
        .pipe(concat(folder + '.css'))
        // write to output
        .pipe(gulp.dest(scriptsPath))
        // write to output again
        .pipe(gulp.dest(scriptsPath));
    });


   return merge(tasks);
    console.log(folders);

});

2 Answers 2

3

You can specify multiple destinations like this:

gulp.task('sass', function () {
    return gulp.src('Css/Clients/**/theme.scss') // Gets all files ending with .scss
    .pipe(sass({outputStyle: 'compact'}))
    .pipe(gulp.dest('app/css'))
    .pipe(gulp.dest('app/Theme'))
    .pipe(gulp.dest('app/Theme1'))
    .pipe(browserSync.reload({
        stream: true
    }))
});
Sign up to request clarification or add additional context in comments.

1 Comment

so the result would be app/Theme1/Theme1.css? cause is exactly what i need just one file per folder
0

Got it thanks guys!

gulp.task('sass', function () {
var folders = getFolders(scriptsPath);

var tasks = folders.map(function(folder) {
    return gulp.src(path.join(scriptsPath, folder, '/**/*.scss'))
    .pipe(sass({outputStyle: 'compact'}))
    // concat into foldername
    .pipe(concat(folder + '.css'))
    // write to output
    .pipe(gulp.dest(scriptsPath+folder))
});

});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.