Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
增加对 css-module 的支持
在 jsx 文件中,通过将 ImportDeclaration 转换为 VariableDeclaration 来实现。
考虑到有全局样式的功能,如用户在
app.jsx
文件中直接使用import './index.css'
,我考虑是更改parseAst
最后产出的styleFiles
还是从文件名来判断是否使用 css-module。如果修改 styleLists 则需要将styleFiles: string[]
改为stylesFiles: { fileName: string, module: boolean }[]
的形式,改动较大。因此我采用了文件名约束的方式,对引入的style.global.css
这种含有.global
的文件名的样式文件不做处理。示例仓库 https://github.com/MrKou47/taro-css-modules