@umijs/preset-umi 4.6.53 → 4.6.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/ssr/builder/assets-loader.js +1 -1
- package/dist/features/ssr/builder/css-loader.d.ts +1 -2
- package/dist/features/ssr/builder/css-loader.js +1 -1
- package/dist/features/ssr/builder/less-loader.js +1 -1
- package/dist/features/ssr/utils.js +17 -0
- package/dist/features/ssr/utoopack/utoopack.js +2 -1
- package/package.json +15 -15
|
@@ -48,7 +48,7 @@ function assetsLoader(opts) {
|
|
|
48
48
|
);
|
|
49
49
|
if ((0, import_fs.existsSync)(args.path) && (0, import_fs.statSync)(args.path).isFile() && (0, import_fs.statSync)(args.path).size < 1e4) {
|
|
50
50
|
return {
|
|
51
|
-
contents: (0, import_fs.readFileSync)(args.path),
|
|
51
|
+
contents: new Uint8Array((0, import_fs.readFileSync)(args.path)),
|
|
52
52
|
loader: "dataurl"
|
|
53
53
|
};
|
|
54
54
|
} else {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import esbuild from '@umijs/bundler-utils/compiled/esbuild';
|
|
3
2
|
export declare function ensureLastSlash(path: string): string;
|
|
4
3
|
export declare function hashString(str: string): string;
|
|
5
|
-
export declare function getClassNames(code:
|
|
4
|
+
export declare function getClassNames(code: Uint8Array, filename: string): string[];
|
|
6
5
|
export declare function cssLoader(opts: {
|
|
7
6
|
cwd: string;
|
|
8
7
|
}): esbuild.Plugin;
|
|
@@ -55,7 +55,7 @@ function cssLoader(opts) {
|
|
|
55
55
|
name: "css-loader",
|
|
56
56
|
setup(build) {
|
|
57
57
|
build.onLoad({ filter: /\.css$/ }, (args) => {
|
|
58
|
-
const code = (0, import_fs.readFileSync)(args.path);
|
|
58
|
+
const code = new Uint8Array((0, import_fs.readFileSync)(args.path));
|
|
59
59
|
const filename = (0, import_utils.winPath)(args.path).replace(
|
|
60
60
|
ensureLastSlash((0, import_utils.winPath)(opts.cwd)),
|
|
61
61
|
""
|
|
@@ -67,7 +67,7 @@ var lessLoader = (opts) => {
|
|
|
67
67
|
paths: [...lessOptions.paths || [], dir]
|
|
68
68
|
});
|
|
69
69
|
const classNames = (0, import_css_loader.getClassNames)(
|
|
70
|
-
Buffer.from(result.css),
|
|
70
|
+
new Uint8Array(Buffer.from(result.css)),
|
|
71
71
|
filename
|
|
72
72
|
).sort();
|
|
73
73
|
const cssModuleObject = classNames.reduce(
|
|
@@ -123,6 +123,19 @@ function walkSourceAssets(dir, cwd, ret = []) {
|
|
|
123
123
|
}
|
|
124
124
|
return ret;
|
|
125
125
|
}
|
|
126
|
+
function isCssFile(file) {
|
|
127
|
+
return /\.css(?:[?#].*)?$/.test(file) && !/\.css\.map(?:[?#].*)?$/.test(file);
|
|
128
|
+
}
|
|
129
|
+
function isUmiCssFile(file) {
|
|
130
|
+
return /^umi(?:\.[a-f0-9]+)?\.css$/i.test((0, import_path.basename)(file.split(/[?#]/)[0]));
|
|
131
|
+
}
|
|
132
|
+
function isUtoopackSingleCss(file) {
|
|
133
|
+
return /\.single\.css(?:[?#].*)?$/.test(file);
|
|
134
|
+
}
|
|
135
|
+
function findClientCssFile(files) {
|
|
136
|
+
const cssFiles = files.filter(isCssFile);
|
|
137
|
+
return cssFiles.find(isUmiCssFile) || cssFiles.find((file) => !isUtoopackSingleCss(file)) || cssFiles[0];
|
|
138
|
+
}
|
|
126
139
|
function getSourceAssetMap(api, statsAssets, publicPath) {
|
|
127
140
|
const outputAssets = statsAssets.filter((file) => assetExts.has((0, import_path.extname)(file))).map((file) => {
|
|
128
141
|
const absPath = (0, import_path.join)(api.paths.absOutputPath, file);
|
|
@@ -184,6 +197,10 @@ var generateBuildManifestFromStats = (api, stats) => {
|
|
|
184
197
|
if (umiJs) {
|
|
185
198
|
finalJsonObj.assets["umi.js"] = addPublicPath(publicPath, umiJs);
|
|
186
199
|
}
|
|
200
|
+
const umiCss = findClientCssFile([...entryFiles, ...statsAssets]);
|
|
201
|
+
if (umiCss) {
|
|
202
|
+
finalJsonObj.assets["umi.css"] = addPublicPath(publicPath, umiCss);
|
|
203
|
+
}
|
|
187
204
|
(0, import_fs.writeFileSync)(buildFilePath, JSON.stringify(finalJsonObj, null, 2), {
|
|
188
205
|
flag: "w"
|
|
189
206
|
});
|
|
@@ -88,7 +88,8 @@ var build = async (api, opts) => {
|
|
|
88
88
|
},
|
|
89
89
|
config: api.config,
|
|
90
90
|
serverBuildPath: absOutputFile,
|
|
91
|
-
useHash
|
|
91
|
+
useHash,
|
|
92
|
+
isDev: api.env === import_types.Env.development
|
|
92
93
|
});
|
|
93
94
|
const serverFile = getServerBuildFile(stats) || (0, import_path.basename)(absOutputFile);
|
|
94
95
|
const jsonFilePath = (0, import_path.join)((0, import_path.dirname)(absOutputFile), "build-manifest.json");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.55",
|
|
4
4
|
"description": "@umijs/preset-umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -43,21 +43,21 @@
|
|
|
43
43
|
"react-router": "6.3.0",
|
|
44
44
|
"react-router-dom": "6.3.0",
|
|
45
45
|
"regenerator-runtime": "0.13.11",
|
|
46
|
-
"@umijs/ast": "4.6.
|
|
47
|
-
"@umijs/
|
|
48
|
-
"@umijs/bundler-
|
|
49
|
-
"@umijs/
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/
|
|
52
|
-
"@umijs/bundler-
|
|
53
|
-
"@umijs/core": "4.6.53",
|
|
54
|
-
"@umijs/mfsu": "4.6.53",
|
|
55
|
-
"@umijs/renderer-react": "4.6.53",
|
|
56
|
-
"@umijs/utils": "4.6.53",
|
|
57
|
-
"@umijs/plugin-run": "4.6.53",
|
|
58
|
-
"@umijs/server": "4.6.53",
|
|
46
|
+
"@umijs/ast": "4.6.55",
|
|
47
|
+
"@umijs/bundler-utoopack": "4.6.55",
|
|
48
|
+
"@umijs/bundler-webpack": "4.6.55",
|
|
49
|
+
"@umijs/renderer-react": "4.6.55",
|
|
50
|
+
"@umijs/core": "4.6.55",
|
|
51
|
+
"@umijs/mfsu": "4.6.55",
|
|
52
|
+
"@umijs/bundler-utils": "4.6.55",
|
|
59
53
|
"@umijs/ui": "3.0.1",
|
|
60
|
-
"@umijs/
|
|
54
|
+
"@umijs/plugin-run": "4.6.55",
|
|
55
|
+
"@umijs/bundler-vite": "4.6.55",
|
|
56
|
+
"@umijs/server": "4.6.55",
|
|
57
|
+
"@umijs/utils": "4.6.55",
|
|
58
|
+
"@umijs/babel-preset-umi": "4.6.55",
|
|
59
|
+
"@umijs/bundler-esbuild": "4.6.55",
|
|
60
|
+
"@umijs/zod2ts": "4.6.55"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@manypkg/get-packages": "1.1.3",
|