I am trying to get Gulp to compile all my LESS files from a LESS folder and then create a CSS folder within their respective Wordpress theme folders compiled into a directory css/main.css file. This is using Wordpress wp-content/themes/theme-name/less as a file structure. Every time I try to compile it throws it into a /themes/** folder or if I use .pipe(gulp.dest('./css/')); it creates it in the root of the project. I want it to create a new css folder in each of the theme folders and compile main.css into each of those folders according to their respective LESS files.
gulp.task('less', ['clean'], function () {
var paths = [
"wp-content/themes/theme-name-1/less/_compile.less",
"wp-content/themes/theme-name-2/less/_compile.less",
"wp-content/themes/theme-name-3/less/_compile.less"
];
var compile = gulp.src(paths, { base: './'})
.pipe(rename({
basename: "main",
extname: ".css"
}))
.pipe(sourcemaps.init())
.pipe(less())
.pipe(autoprefixer())
.pipe(sourcemaps.write('./css'))
.pipe(gulp.dest('wp-content/themes/**/css'));
return (compile);
});
The way I want it to occur is:
When you run gulp it compiles and creates a folder: wp-content/themes/theme-name/css from wp-content/themes/theme-name/less. I want it to look in each theme-name folder and create a respective /css/ folder with the compiled less being main.css.
Right now it seems to be creating a ** folder in the root of wp-content/themes.