in packages/babel-plugin-wind-rc/lib/index.js [31:80]
ImportDeclaration(path) {
const { source } = path.node
if (!isStringLiteral(source)) {
return
}
const { value: sourceValue } = source
const exactExcludePatterns = transPatterns(excludePatterns)
if (Array.isArray(exactExcludePatterns)) {
for (const pattern of exactExcludePatterns) {
if (pattern.test(sourceValue)) {
return
}
}
}
const exactIncludePatterns = transPatterns(includePatterns)
if (
!Array.isArray(exactIncludePatterns) ||
!exactIncludePatterns.length
) {
console.warn(
'[babel-plugin-wind-rc] ' +
'It will be not importing related css files automatically, ' +
'because the plugin cannot find any import sources ' +
'that can be matched `includePatterns`.'
)
return
}
let canBeInject = false
_.forEach(exactIncludePatterns, (pattern) => {
if (pattern.test(sourceValue)) {
canBeInject = true
}
})
if (canBeInject) {
path.insertBefore(
importDeclaration(
[],
stringLiteral(`${sourceValue}/${cssFilePath}`)
)
)
}
},