Skip to content

Commit

Permalink
fix: assets rule in speedup mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Nov 7, 2023
1 parent 4a7340a commit 0a79004
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-pillows-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/rspack-config': patch
---

fix: assets rule for rspack
13 changes: 5 additions & 8 deletions packages/rspack-config/src/assetsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import type { Configuration } from '@rspack/core';

const getAssetsRule = () => {
const assetsRule = [
[/\.woff2?$/, { mimetype: 'application/font-woff' }],
[/\.ttf$/, { mimetype: 'application/octet-stream' }],
[/\.eot$/, { mimetype: 'application/vnd.ms-fontobject' }],
[/\.svg$/, { mimetype: 'image/svg+xml' }, false],
[/\.woff2?$/], [/\.ttf$/], [/\.eot$/], [/\.svg$/],
[/\.(png|jpg|webp|jpeg|gif)$/i],
];

Expand All @@ -21,13 +18,13 @@ const getAssetsRule = () => {
return {
test,
type: 'asset',
parser: {
...(urlCondition ? {
...(urlCondition ? {
parser: {
dataUrlCondition: {
maxSize: 8 * 1024, // 8kb
},
} : {}),
},
},
} : {}),
...(typeof ruleOption === 'object' ? ruleOption : {}),
};
}) as Configuration['module']['rules']).concat(queryRules);
Expand Down

0 comments on commit 0a79004

Please sign in to comment.