SassNinja / media-query-plugin

Webpack plugin for media query extraction.
MIT License
205 stars 27 forks source link

Feature: Control output filename option #51

Open themaxsandelin opened 4 years ago

themaxsandelin commented 4 years ago

I started using this plugin in my current project at work and found two major things we needed for this to work properly in our setup. We are using a Vue setup with Webpack that builds everything together, nothing too fancy. The issue was that the files were all named index.vue, simply for ease of use in import/require instances. And instead, the components would have a unique folder, named after the component, that would then contain a index.vue file.

This caused an issue where we didn't have the option to either define components to be included, because all components were named index according to the plugin. And if we included all the components, using the include: true; option, they would all overwrite each other as index-[queryname].css files.

This PR adds an option to control the output filename for each extracted CSS, allowing us in this case to use the file path to determine the correct filename.

This is of course not necessary to add to your plugin, as we can use my fork of it. But I figured it could be useful for other people. 🙂