Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow module config while using autoModules (#281) #292

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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