Skip to content

Commit 84f1e27

Browse files
committed
prioritize main file load
1 parent e968c87 commit 84f1e27

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

packages/suite-build/configs/web.webpack.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { FLAGS, routes } from '@suite-common/suite-config';
99
import { assetPrefix, isDev } from '../utils/env';
1010
import { getPathForProject } from '../utils/path';
1111

12+
const PreloadWebpackPlugin = require('@vue/preload-webpack-plugin');
13+
1214
const baseDir = getPathForProject('web');
1315
const config: webpack.Configuration = {
1416
target: 'browserslist',
@@ -74,6 +76,18 @@ const config: webpack.Configuration = {
7476
/@trezor\/connect$/,
7577
'@trezor/connect-web/src/module',
7678
),
79+
new PreloadWebpackPlugin({
80+
rel: 'preload',
81+
include: 'allChunks',
82+
fileWhitelist: [/^main\.[^.]+\.js$/],
83+
}),
84+
new PreloadWebpackPlugin({
85+
rel: 'preconnect',
86+
include: 'asyncChunks',
87+
// NOTE: only prefetch js files
88+
fileWhitelist: [/\.js$/],
89+
fileBlacklist: [/_svg\.js$/, /date-fns/, /json\.js/, /suite-data/],
90+
}),
7791
...(!isDev ? [new CssMinimizerPlugin()] : []),
7892
],
7993
};

packages/suite-build/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@suite-common/suite-config": "workspace:*",
2626
"@trezor/bundler-security": "workspace:*",
2727
"@trezor/suite": "workspace:*",
28+
"@vue/preload-webpack-plugin": "^2.0.0",
2829
"babel-loader": "^9.1.3",
2930
"babel-plugin-styled-components": "^2.1.4",
3031
"copy-webpack-plugin": "^12.0.2",

yarn.lock

+11
Original file line numberDiff line numberDiff line change
@@ -12348,6 +12348,7 @@ __metadata:
1234812348
"@types/node-fetch": "npm:^2.6.12"
1234912349
"@types/webpack-bundle-analyzer": "npm:^4.7.0"
1235012350
"@types/webpack-plugin-serve": "npm:^1.4.6"
12351+
"@vue/preload-webpack-plugin": "npm:^2.0.0"
1235112352
babel-loader: "npm:^9.1.3"
1235212353
babel-plugin-styled-components: "npm:^2.1.4"
1235312354
copy-webpack-plugin: "npm:^12.0.2"
@@ -14734,6 +14735,16 @@ __metadata:
1473414735
languageName: node
1473514736
linkType: hard
1473614737

14738+
"@vue/preload-webpack-plugin@npm:^2.0.0":
14739+
version: 2.0.0
14740+
resolution: "@vue/preload-webpack-plugin@npm:2.0.0"
14741+
peerDependencies:
14742+
html-webpack-plugin: ^5.0.0 || ^4.5.1
14743+
webpack: ^5.20.0 || ^4.1.0
14744+
checksum: 10/ddaf1542b2cdece5619eb836c96cc177153b8b1a55833d279358d7042d869e916b461e0fc7e8372504a479b8b8c135885b10738bb9a241c5ae542099deef6341
14745+
languageName: node
14746+
linkType: hard
14747+
1473714748
"@vue/shared@npm:3.4.27":
1473814749
version: 3.4.27
1473914750
resolution: "@vue/shared@npm:3.4.27"

0 commit comments

Comments
 (0)