Skip to content

Commit 55d37e9

Browse files
authored
fix(builder): should not print file size of LICENSE.text (#3746)
1 parent de8bdad commit 55d37e9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.changeset/gold-dingos-occur.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/builder': patch
3+
---
4+
5+
fix(builder): should not print file size of LICENSE.text
6+
7+
fix(builder): 打印文件体积时忽略 LICENSE.text

packages/builder/builder/src/plugins/fileSize.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import {
1212
} from '@modern-js/builder-shared';
1313
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
1414

15-
/** Filter source map files */
16-
export const filterAsset = (asset: string) => !/\.map$/.test(asset);
15+
/** Filter source map and license files */
16+
export const filterAsset = (asset: string) =>
17+
!/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
1718

1819
const getAssetColor = (size: number) => {
1920
if (size > 300 * 1000) {

packages/builder/builder/tests/plugins/fileSize.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ describe('plugins/fileSize', () => {
77
expect(filterAsset('dist/a.css')).toBeTruthy();
88
expect(filterAsset('dist/a.js.map')).toBeFalsy();
99
expect(filterAsset('dist/b.css.map')).toBeFalsy();
10+
expect(filterAsset('dist/a.js.LICENSE.txt')).toBeFalsy();
11+
expect(filterAsset('dist/b.css.LICENSE.txt')).toBeFalsy();
1012
expect(filterAsset('dist/a.png')).toBeTruthy();
1113
});
1214
});

0 commit comments

Comments
 (0)