-
Notifications
You must be signed in to change notification settings - Fork 280
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: import style from less error when build in babel way #220
Conversation
detaile: umijs#218
Codecov Report
@@ Coverage Diff @@
## 2.x #220 +/- ##
==========================================
+ Coverage 73.39% 74.16% +0.77%
==========================================
Files 16 16
Lines 466 480 +14
Branches 158 164 +6
==========================================
+ Hits 342 356 +14
Misses 123 123
Partials 1 1
Continue to review full report at Codecov.
|
组件开发,不应该在
import React from 'react';
import Styles from './index.less';
import Classnames from 'classnames';
import { Divider } from 'antd';
export default ({ title }: { title: string }) => (
<h1 className={Classnames(Styles['foo-center'])}>
<Divider type="vertical" />
{title}
<Divider type="vertical" />
</h1>
); 正确示例: import React from 'react';
// import Styles from './index.less';
import Classnames from 'classnames';
import { Divider } from 'antd';
export default ({ title }: { title: string }) => (
<h1 className={Classnames('foo-center')}>
<Divider type="vertical" />
{title}
<Divider type="vertical" />
</h1>
); |
有些场景是需要在js中引入css的,所以我又打开了哈 |
@@ -128,7 +128,8 @@ export default async function(opts: IBabelOpts) { | |||
const babelTransformRegexp = disableTypeCheck ? /\.(t|j)sx?$/ : /\.jsx?$/; | |||
|
|||
function isTsFile(path) { | |||
return /\.tsx?$/.test(path) && !path.endsWith('.d.ts'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是每个 TS 项目都有 .d.ts
的吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
给个默认的 .d.ts
? 就像 template/tsconfig.json
一样?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
其实 .d.ts
有没有不重要,没有的话,就和原来一样,我这里仅仅是把根目录下的 typings.d.ts
加到了匹配规则,并进入了 gulp-typescript
编译
关键是 typings.d.ts
有点问题,因为也有可能是 index.d.ts
、typings/index.d.ts
等,由于我的项目是用脚手架@umijs/dumi-lib
创建的,所以我就用了typings.d.ts
,没考虑全面,
感觉可以多匹配几个,然后再 在 tsconfig.json
里面取匹配项 兜底,
这样可行不?
patterns add include
❤ 感觉这么用还是有点 workaround,无法获得和 tsc 一样的行为;该问题请先参考临时方案绕开,再帮忙一起想想有没有更好的解法,比如是否能启用 gulp-typescript 的 project 模式解决。 此 PR 就先关闭了。 |
detaile: #218
Checklist
npm test
passesDescription of change
issues: #218
babel.ts:
const patterns = [ + join(srcPath, '../typings.d.ts'), join(srcPath, '**/*'), `!${join(srcPath, '**/fixtures{,/**}')}`, `!${join(srcPath, '**/demos{,/**}')}`,