Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
242 stars 43 forks source link

Allow `autoModules` to be used together with `modules` #166

Open frankieyan opened 3 years ago

frankieyan commented 3 years ago

Hi there, it looks like when a modules config object is provided, then the regex match using autoModules is ignored:

https://github.com/Anidetrix/rollup-plugin-styles/blob/e09ac0927053ffba52410e1d36b6b1c74ae63155/src/loaders/postcss/index.ts#L49

For example, using a configuration like the following would result in all stylesheets being treated as modules, rather than just *.module.css:

  styles({
    autoModules: /\.module\.css$/,
    modules: {
        mode: 'local',
        generateScopedName: '[hash]',
    },
  }),

Would you welcome a change to something like the following?

const supportModules = Boolean((!options.autoModules && options.modules) || autoModules)