Skip to content
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

feat: svgr fallback to file-loader when using big file #10796

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/bundler-webpack/compiled/file-loader/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions packages/bundler-webpack/compiled/file-loader/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/bundler-webpack/compiled/file-loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"file-loader","version":"6.2.0","author":"Tobias Koppers @sokra","license":"MIT"}
3 changes: 3 additions & 0 deletions packages/bundler-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"copy-webpack-plugin": "10.2.4",
"css-minimizer-webpack-plugin": "4.0.0",
"cssnano": "5.1.7",
"file-loader": "6.2.0",
"less-loader": "11.1.0",
"mini-css-extract-plugin": "2.7.2",
"postcss-flexbugs-fixes": "5.0.2",
Expand Down Expand Up @@ -115,6 +116,7 @@
"terser",
"terser-webpack-plugin",
"url-loader",
"file-loader",
"webpack-5-chain",
"webpack-bundle-analyzer",
"webpack-dev-middleware",
Expand Down Expand Up @@ -180,6 +182,7 @@
"style-loader",
"svgo-loader",
"url-loader",
"file-loader",
"webpack-bundle-analyzer",
"webpack-dev-middleware",
"webpack-manifest-plugin"
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/config/assetRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IOpts {
export async function addAssetRules(opts: IOpts) {
const { config, userConfig } = opts;

const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
const inlineLimit = userConfig.inlineLimit;
const rule = config.module.rule('asset');

rule
Expand Down
2 changes: 2 additions & 0 deletions packages/bundler-webpack/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export async function getConfig(opts: IOpts): Promise<Configuration> {
const isDev = opts.env === Env.development;
const config = new Config();
userConfig.targets ||= DEFAULT_BROWSER_TARGETS;
// normalize inline limit
userConfig.inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
const useHash = !!(opts.hash || (userConfig.hash && !isDev));
const applyOpts = {
name: opts.name,
Expand Down
6 changes: 6 additions & 0 deletions packages/bundler-webpack/src/config/svgRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ export async function addSVGRules(opts: IOpts) {
.end()
.use('url-loader')
.loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
.options({
limit: userConfig.inlineLimit,
fallback: require.resolve(
'@umijs/bundler-webpack/compiled/file-loader',
),
})
.end();
}
if (svgo !== false) {
Expand Down
28 changes: 24 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.