Search code examples
gulpgulp-clean-css

EACCES: permission denied on gulp css minify, same src and dest


I have a gulp task to build up everything which runs for dev (works fine). On release gulp task we do the same but also tack on a bundle task which also minifies the css.

I want to just minify the css inline, meaning the same src and dest for the file; however, I am getting the below error when running.

Error: EACCES: permission denied, open

I don't think I'm hitting any race conditions since my build task shows as finished before the minify starts

[15:11:48] Finished 'build_client_lib' after 3.31 s
[15:11:48] Starting 'build'...
[15:11:48] Finished 'build' after 1.67 μs
[15:11:48] Starting 'minify-css'...
[15:11:48] 'minify-css' errored after 344 ms

The tasks in question are:

gulp.task('release', callback => {
  gulpSequence('clean_packages', 'build', 'client_lib_bundle')(callback)
});

gulp.task('client_lib_bundle', ['minify-css'], () => {

});

gulp.task('minify-css', () => {
  return gulp.src('build/client_lib/**/*.css')
    .pipe(cleanCSS())
    .pipe(gulp.dest('build/client_lib'));
});

It works fine is I specify an alternate dest path, but I'd prefer not to do that. How can I resolve this access issue?


Solution

  • Turns out the package I was using gulpSequence caused this, and a slew of other items, to run in an awkwardly async manner. Changing to the npm package run-sequence cleared all this up and ensures everything is running in the correct order.