I need to define the conditional output in gulp.dest. To do it, I need to know full source path of every file. Here how I do it for SASS task and how I want to do same thing for webpack:
const SASS_SOURCE_FILES_SELECTOR = [
'development/source/public/sass/**/*.sass',
'development/source/admin/sass/**/*.sass'],
PUBLIC_FOLDER_NAME = 'public',
ADMIN_FOLDER_NAME = 'admin';
gulp.task('sass', function(){
return gulp.src(SASS_SOURCE_FILES_SELECTOR)
.pipe(sass())
.pipe(gulp.dest( file => {
let pathSegments = file.dirname.split(path.sep);
let pathSegmentsCount = pathSegments.length;
for (let i = pathSegmentsCount - 1; i > 0; i--) {
switch (pathSegments[i]) {
case PUBLIC_FOLDER_NAME: {
return `${file.cwd}\\development\\devBuild\\${PUBLIC_FOLDER_NAME}\\js`;
}
case ADMIN_FOLDER_NAME: {
return `${file.cwd}\\development\\devBuild\\${ADMIN_FOLDER_NAME}\\js`;
}
default:{
break;
}
}
}
}));
});
Thank you for the amazing package. Thanks to you, I don't need
webpack.config.js
and separatewebpack
launch anymore.In the following experiment, I explored than
gulp-webpack
doing something withfile
object:I need to define the conditional output in
gulp.dest
. To do it, I need to know full source path of every file. Here how I do it for SASS task and how I want to do same thing for webpack: