SassNinja / postcss-extract-media-query

PostCSS plugin to extract all media query from CSS and emit as separate files.
MIT License
130 stars 20 forks source link

Proposal: attach processing to OnceExit hook #39

Open bart-jaskulski opened 2 years ago

bart-jaskulski commented 2 years ago

Right now processing exported files is done by reapplying plugins to extracted files, but I could be possible just to rely on the order of execution, and thus putting postcss-extract-media-query as the last plugin in stack, after processing by other plugins.

Attaching to OnceExit postcss hook (instead of Once) ensures that the plugin code is executed at the end.

module.exports = {
  plugins = [
    require('cssnano'),
    require('postcss-extract-media-query')({
      output: { path: './' }
    })
  ]
}

Config above would firstly minify our css file, then extract it to separate files, with processing applied. At the moment it is possible only by attaching additional config to in plugin settings, which specifies that we want to minify our files.

The change, I mention would take care of such processing mostly out of the box, but it would possibly be a breaking change, because it would require a correct order of declaring plugins in postcss.config.js