Skip to content

Commit 26d8cc5

Browse files
author
kovenliao
committed
support babel 7
1 parent 64f1f5e commit 26d8cc5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/index.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ export default function transformCssModules({ types: t }) {
9999
// find options for this plugin
100100
// we have to use this hack because plugin.key does not have to be 'css-modules-transform'
101101
// so we will identify it by comparing manipulateOptions
102-
thisPluginOptions = options.plugins.filter(
103-
([plugin]) => plugin.manipulateOptions === pluginApi.manipulateOptions
104-
)[0][1];
102+
if (Array.isArray(options.plugins[0])) { // babel 6
103+
thisPluginOptions = options.plugins.filter(
104+
([plugin]) => plugin.manipulateOptions === pluginApi.manipulateOptions
105+
)[0][1];
106+
} else { // babel 7
107+
thisPluginOptions = options.plugins.filter(
108+
(plugin) => plugin.manipulateOptions === pluginApi.manipulateOptions
109+
)[0].options;
110+
}
105111

106112
const currentConfig = { ...defaultOptions, ...thisPluginOptions };
107113
// this is not a css-require-ook config

0 commit comments

Comments
 (0)