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的,所以我又打开了哈 |
| 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.
给个默认的 .d.ts? 就像 template/tsconfig.json 一样?
There was a problem hiding this comment.
其实 .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 testpassesDescription of change
issues: #218
babel.ts:
const patterns = [ + join(srcPath, '../typings.d.ts'), join(srcPath, '**/*'), `!${join(srcPath, '**/fixtures{,/**}')}`, `!${join(srcPath, '**/demos{,/**}')}`,