Skip to content

Commit

Permalink
fix: allow module config while using autoModules (egoist#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
katywings committed Jun 26, 2020
1 parent 9489eca commit 5e5c5b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions src/postcss-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')({
Expand Down
1 change: 1 addition & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ snapshotMany('modules', [
title: 'inject-object',
input: 'css-modules/index.js',
options: {
autoModules: false,
modules: {
getJSON() {
//
Expand Down

0 comments on commit 5e5c5b7

Please sign in to comment.