@umijs/bundler-utoopack 4.6.54 → 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/config.js +0 -1
- package/dist/util.d.ts +21 -0
- package/dist/util.js +67 -2
- package/package.json +4 -4
package/dist/config.js
CHANGED
|
@@ -468,7 +468,6 @@ async function getSSRUtooPackConfig(opts) {
|
|
|
468
468
|
path: (0, import_path.dirname)(opts.serverBuildPath),
|
|
469
469
|
filename,
|
|
470
470
|
chunkFilename: filename,
|
|
471
|
-
...opts.isDev ? { assetModuleFilename: "[name].[contenthash:8]" } : {},
|
|
472
471
|
clean: true,
|
|
473
472
|
copy: [],
|
|
474
473
|
publicPath: "/"
|
package/dist/util.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WebpackConfig } from '@utoo/pack';
|
|
1
2
|
declare type IDevBannerOpts = {
|
|
2
3
|
duration?: number;
|
|
3
4
|
host?: string;
|
|
@@ -13,6 +14,26 @@ declare type IBuildBannerOpts = {
|
|
|
13
14
|
packVersion?: string;
|
|
14
15
|
};
|
|
15
16
|
export declare function getPackVersion(packVersion?: string): any;
|
|
17
|
+
export declare function getCssOutputFilenames(opts: {
|
|
18
|
+
entry: Record<string, string>;
|
|
19
|
+
config: Record<string, any>;
|
|
20
|
+
webpackConfig: WebpackConfig;
|
|
21
|
+
useHash: boolean;
|
|
22
|
+
}): {
|
|
23
|
+
cssChunkFilename: string;
|
|
24
|
+
cssFilename?: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare function getSSRCssSplitChunks(config: Record<string, any>): {
|
|
27
|
+
splitChunks?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
splitChunks: {
|
|
30
|
+
css: {
|
|
31
|
+
minChunkSize: number;
|
|
32
|
+
maxChunkCountPerGroup: number;
|
|
33
|
+
maxMergeChunkSize: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
16
37
|
export declare function getDevBanner({ protocol, host, port, ip, packVersion, duration, }: IDevBannerOpts): string;
|
|
17
38
|
export declare function getBuildBanner({ packVersion, duration, outputPath, assetCount, }: IBuildBannerOpts): string;
|
|
18
39
|
export {};
|
package/dist/util.js
CHANGED
|
@@ -20,8 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var util_exports = {};
|
|
21
21
|
__export(util_exports, {
|
|
22
22
|
getBuildBanner: () => getBuildBanner,
|
|
23
|
+
getCssOutputFilenames: () => getCssOutputFilenames,
|
|
23
24
|
getDevBanner: () => getDevBanner,
|
|
24
|
-
getPackVersion: () => getPackVersion
|
|
25
|
+
getPackVersion: () => getPackVersion,
|
|
26
|
+
getSSRCssSplitChunks: () => getSSRCssSplitChunks
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(util_exports);
|
|
27
29
|
var import_utils = require("@umijs/utils");
|
|
@@ -56,6 +58,67 @@ function formatDuration(duration) {
|
|
|
56
58
|
}
|
|
57
59
|
return `${Math.max(0, Math.round(duration))}ms`;
|
|
58
60
|
}
|
|
61
|
+
function normalizeUtoopackFilenameTemplate(filename) {
|
|
62
|
+
return filename.replace(
|
|
63
|
+
/\[(?:hash|chunkhash)(?::(\d+))?\]/g,
|
|
64
|
+
(_, length) => `[contenthash${length ? `:${length}` : ""}]`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function getMiniCssExtractPluginOptions(webpackConfig) {
|
|
68
|
+
var _a;
|
|
69
|
+
const plugin = (_a = webpackConfig.plugins) == null ? void 0 : _a.find((p) => {
|
|
70
|
+
var _a2;
|
|
71
|
+
return p && typeof p === "object" && ((_a2 = p.constructor) == null ? void 0 : _a2.name) === "MiniCssExtractPlugin";
|
|
72
|
+
});
|
|
73
|
+
return plugin == null ? void 0 : plugin.options;
|
|
74
|
+
}
|
|
75
|
+
function getEntryCssFilename(entry, filenameTemplate, replaceName) {
|
|
76
|
+
const normalizedFilenameTemplate = normalizeUtoopackFilenameTemplate(filenameTemplate);
|
|
77
|
+
if (!replaceName) {
|
|
78
|
+
return normalizedFilenameTemplate;
|
|
79
|
+
}
|
|
80
|
+
const entryNames = Object.keys(entry || {});
|
|
81
|
+
if (entryNames.length !== 1) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
return normalizedFilenameTemplate.replace(/\[name\]/g, entryNames[0]);
|
|
85
|
+
}
|
|
86
|
+
function getCssOutputFilenames(opts) {
|
|
87
|
+
const miniCssExtractOptions = getMiniCssExtractPluginOptions(
|
|
88
|
+
opts.webpackConfig
|
|
89
|
+
);
|
|
90
|
+
const hash = opts.useHash ? ".[contenthash:8]" : "";
|
|
91
|
+
const cssFilenameTemplate = typeof (miniCssExtractOptions == null ? void 0 : miniCssExtractOptions.filename) === "string" ? miniCssExtractOptions.filename : `[name]${hash}.css`;
|
|
92
|
+
let cssChunkFilenameTemplate = typeof (miniCssExtractOptions == null ? void 0 : miniCssExtractOptions.chunkFilename) === "string" ? miniCssExtractOptions.chunkFilename : void 0;
|
|
93
|
+
if (!cssChunkFilenameTemplate) {
|
|
94
|
+
cssChunkFilenameTemplate = opts.config.ssr ? `umi${hash}.css` : `[name]${hash}.chunk.css`;
|
|
95
|
+
}
|
|
96
|
+
const cssFilename = getEntryCssFilename(
|
|
97
|
+
opts.entry,
|
|
98
|
+
cssFilenameTemplate,
|
|
99
|
+
!!opts.config.ssr
|
|
100
|
+
);
|
|
101
|
+
return {
|
|
102
|
+
...cssFilename ? { cssFilename } : {},
|
|
103
|
+
cssChunkFilename: normalizeUtoopackFilenameTemplate(
|
|
104
|
+
cssChunkFilenameTemplate
|
|
105
|
+
)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function getSSRCssSplitChunks(config) {
|
|
109
|
+
if (!config.ssr) {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
splitChunks: {
|
|
114
|
+
css: {
|
|
115
|
+
minChunkSize: 1e8,
|
|
116
|
+
maxChunkCountPerGroup: 1,
|
|
117
|
+
maxMergeChunkSize: 1e8
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
59
122
|
function getDevBanner({
|
|
60
123
|
protocol,
|
|
61
124
|
host,
|
|
@@ -125,6 +188,8 @@ function getBuildBanner({
|
|
|
125
188
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
189
|
0 && (module.exports = {
|
|
127
190
|
getBuildBanner,
|
|
191
|
+
getCssOutputFilenames,
|
|
128
192
|
getDevBanner,
|
|
129
|
-
getPackVersion
|
|
193
|
+
getPackVersion,
|
|
194
|
+
getSSRCssSplitChunks
|
|
130
195
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.55",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@utoo/pack": "1.4.
|
|
11
|
+
"@utoo/pack": "1.4.7",
|
|
12
12
|
"compression": "^1.7.4",
|
|
13
13
|
"connect-history-api-fallback": "^2.0.0",
|
|
14
14
|
"cors": "^2.8.5",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"resolve-url-loader": "5.0.0",
|
|
21
21
|
"sass": "1.54.0",
|
|
22
22
|
"sass-loader": "13.2.0",
|
|
23
|
-
"@umijs/bundler-utils": "4.6.
|
|
24
|
-
"@umijs/bundler-webpack": "4.6.
|
|
23
|
+
"@umijs/bundler-utils": "4.6.55",
|
|
24
|
+
"@umijs/bundler-webpack": "4.6.55"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"father": "4.1.5"
|