leinelissen / laravel-mix-react-css-modules

A wrapper for babel-plugin-react-css-modules for Laravel Mix
MIT License
22 stars 9 forks source link

v2: Implement CSS extraction using mini-css-extract-plugin #16

Closed PimButton closed 3 years ago

PimButton commented 3 years ago

This PR adds a configuration flag to extract the compiled CSS into a separate file.

Motivation For production builds there are advantages to extract the CSS into a separate file:

Changes By adding a configuration flag the user has total control over using CSS extraction or not. The flag is false by default to not introduce a breaking change. Because v3 of this plugin is not yet final and Laravel Mix V5 is still used a lot this PR is based on v2 of the plugin.

Usage Set mix.reactCSSModules(null, true) to enable CSS extraction. Then load the compiled CSS in your Blade file using Mix: <link rel="stylesheet" href="{{mix('js/app.css')}}">