Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How make it works with Gulp 4 (and gulp-postcss)? #71

Closed
equinusocio opened this issue Jan 3, 2018 · 6 comments
Closed

How make it works with Gulp 4 (and gulp-postcss)? #71

equinusocio opened this issue Jan 3, 2018 · 6 comments

Comments

@equinusocio
Copy link

equinusocio commented Jan 3, 2018

Problem

Make postcss plugins load from postcss.config.js with a Gulp 4 task and gulp-postcss. Is there a way?

Issue [ Code ]

My simply gulp 4 postcss task

export const pcss = (done) => {
  return gulp.src(`${pkg.paths.elements}/**/*.pcss`)
    .pipe(postcss(->PLUGINS<-))
    .pipe(gulp.dest('./'));

  done();
}

gulp.task('postcss', pcss);

Environment

Please provide information about your environment.

OS Node npm PostCSS
Mac OS 9.2.1 5.6.0 4.1.1
@michael-ciniawsky
Copy link
Owner

michael-ciniawsky commented Jan 3, 2018

$ROOT
|– src
| |– imports
| | |– import.pcss
| |– index.pcss
|
|– gulpfile.js
|– postcss.config.js
|– package.json

postcss.config.js

module.exports = (ctx) => ({
   plugins: {
      'postcss-plugin': {...options}
   }
})

gulpfile.js

export const pcss = (done) => {
  return gulp.src(`${pkg.paths.elements}/**/*.pcss`)
    .pipe(postcss())
    .pipe(gulp.dest('./'));

  done();
}

Should work out-of-the-box

@equinusocio
Copy link
Author

equinusocio commented Jan 3, 2018

I also need to require/import postcss-load-plugins inside the gulpfile.babel.js?

@michael-ciniawsky
Copy link
Owner

michael-ciniawsky commented Jan 3, 2018

You don't need to install anything. gulp-postcss has postcss-load-config as a direct dependency, that's what I meant by out-of-the-box 😛

@equinusocio
Copy link
Author

equinusocio commented Jan 3, 2018

Ah so just putting the postcss.config.js file all plugins will be auto-imported with relative
configs? :)

@equinusocio
Copy link
Author

Thank you solved :)

@michael-ciniawsky
Copy link
Owner

Ah so just putting the postcss.config.js file all plugins will be auto-imported with relative
configs? :)

Yep :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants