From 5e5c5b7ccfc872096409a634505bdf2c75a0ccf7 Mon Sep 17 00:00:00 2001 From: Katja Lutz Date: Fri, 26 Jun 2020 19:55:06 +0200 Subject: [PATCH] fix: allow module config while using autoModules (#281) Refs developit/microbundle#653, developit/microbundle#617 --- src/index.js | 1 + src/postcss-loader.js | 5 +++-- test/index.test.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index a6920efe..0f11d62a 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,7 @@ export default (options = {}) => { /** Extract CSS */ extract: typeof options.extract === 'undefined' ? false : options.extract, /** CSS modules */ + onlyModules: options.modules === true, modules: inferOption(options.modules, false), namedExports: options.namedExports, /** Automatically CSS modules for .module.xxx files */ diff --git a/src/postcss-loader.js b/src/postcss-loader.js index c0591c43..2f6e0ffb 100644 --- a/src/postcss-loader.js +++ b/src/postcss-loader.js @@ -70,8 +70,9 @@ export default { const shouldInject = options.inject const modulesExported = {} - const autoModules = options.autoModules !== false && isModuleFile(this.id) - const supportModules = options.modules || autoModules + const autoModules = options.autoModules !== false && options.onlyModules !== true + const isAutoModule = autoModules && isModuleFile(this.id) + const supportModules = autoModules ? isAutoModule : options.modules if (supportModules) { plugins.unshift( require('postcss-modules')({ diff --git a/test/index.test.js b/test/index.test.js index c66e0b20..a6bf49f8 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -198,6 +198,7 @@ snapshotMany('modules', [ title: 'inject-object', input: 'css-modules/index.js', options: { + autoModules: false, modules: { getJSON() { //