generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reactCSS 在生产环境下不产出 map 和 next,因此需要调整判断编译产物的逻辑
- Loading branch information
Showing
3 changed files
with
31 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { isReactCssResult } from './index'; | ||
|
||
describe('isReactCssResult', () => { | ||
it('测试构建产物', () => { | ||
const result = isReactCssResult({ | ||
name: '1mf3e6p', | ||
styles: | ||
'\n grid-area: footer;\n border-top: 1px solid rgba(5, 5, 5, 0.06);\n color: rgba(61, 62, 64, 0.45);\n font-size: 14px;\n line-height: 26px;\n text-align: center;\n padding: 24px 0;\n align-self: stretch;\n @media (max-width: 575px) {\n flex-direction: column;\n }\n ', | ||
}); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('测试dev产物', () => { | ||
const result = isReactCssResult({ | ||
name: '1mf3e6p', | ||
map: undefined, | ||
next: undefined, | ||
styles: | ||
'\n grid-area: footer;\n border-top: 1px solid rgba(5, 5, 5, 0.06);\n color: rgba(61, 62, 64, 0.45);\n font-size: 14px;\n line-height: 26px;\n text-align: center;\n padding: 24px 0;\n align-self: stretch;\n @media (max-width: 575px) {\n flex-direction: column;\n }\n ', | ||
toString: () => {}, | ||
}); | ||
expect(result).toBeTruthy(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* 判断是否是 ReactCss 的编译产物 | ||
* @param params | ||
*/ | ||
export const isReactCssResult = (params: any) => | ||
typeof params === 'object' && 'styles' in params && 'name' in params && 'toString' in params; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1 @@ | ||
/** | ||
* 判断是否是 ReactCss 的编译产物 | ||
* @param params | ||
*/ | ||
export const isReactCssResult = (params: any) => { | ||
return ( | ||
typeof params === 'object' && | ||
'styles' in params && | ||
'name' in params && | ||
'map' in params && | ||
'next' in params && | ||
'toString' in params | ||
); | ||
}; | ||
export * from './css'; |