Last active
September 5, 2019 16:51
-
-
Save jaysoo/431828f47e5202d3e4afc6c34fdac2c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getConfig = require('@nrwl/react/plugins/babel'); | |
const cssModuleRegex = /\.module\.css$/; | |
module.exports = (config) => { | |
config = getConfig(config); | |
config.module.rules.forEach((rule, idx) => { | |
// Find rule tests for CSS. | |
// Then make sure it excludes .module.css files. | |
if (rule.test.test('foo.css')) { | |
rule.exclude = rule.exclude | |
? Array.isArray(rule.exclude) | |
? [...rule.exclude, cssModuleRegex] | |
: [rule.exclude, cssModuleRegex] | |
: cssModuleRegex | |
} | |
}); | |
// Add new rule to handle .module.css files by using css-loader | |
// with modules on. | |
config.module.rules.push({ | |
test: /\.module\.css$/, | |
use: [ | |
{ loader: 'style-loader' }, | |
{ loader: 'css-modules-typescript-loader' }, | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true, | |
importLoaders: 1 | |
} | |
} | |
] | |
}); | |
return config; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment