@umijs/bundler-utoopack 4.6.55 → 4.6.57
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.d.ts +1 -1
- package/dist/config.js +23 -3
- package/dist/types.d.ts +1 -1
- package/package.json +4 -4
package/dist/config.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export declare type IDevOpts = {
|
|
|
35
35
|
onBeforeMiddleware?: Function;
|
|
36
36
|
disableCopy?: boolean;
|
|
37
37
|
clean?: boolean;
|
|
38
|
-
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
|
|
38
|
+
} & Pick<IConfigOpts, 'cache' | 'pkg' | 'staticPathPrefix'>;
|
|
39
39
|
export declare function getDevUtooPackConfig(opts: IDevOpts): Promise<BundleOptions>;
|
package/dist/config.js
CHANGED
|
@@ -40,6 +40,11 @@ var import_utils = require("@umijs/utils");
|
|
|
40
40
|
var import_pack = require("@utoo/pack");
|
|
41
41
|
var import_fs = __toESM(require("fs"));
|
|
42
42
|
var import_path = require("path");
|
|
43
|
+
var DEFAULT_STATIC_PATH_PREFIX = "static/";
|
|
44
|
+
function getAssetModuleFilename(staticPathPrefix) {
|
|
45
|
+
const prefix = staticPathPrefix !== void 0 ? staticPathPrefix : DEFAULT_STATIC_PATH_PREFIX;
|
|
46
|
+
return `${prefix}[name].[contenthash:8]`;
|
|
47
|
+
}
|
|
43
48
|
function getUtoopackDefine(opts) {
|
|
44
49
|
const define = Object.fromEntries(
|
|
45
50
|
Object.entries(opts.config.define || {}).map(([key, value]) => {
|
|
@@ -195,8 +200,17 @@ function getExtraBabelModuleRules(opts) {
|
|
|
195
200
|
}
|
|
196
201
|
};
|
|
197
202
|
}
|
|
203
|
+
function normalizeUtoopackPath(path) {
|
|
204
|
+
return path.replace(/\\/g, "/");
|
|
205
|
+
}
|
|
198
206
|
function getNormalizedAlias(alias, rootDir) {
|
|
199
|
-
const newAlias =
|
|
207
|
+
const newAlias = Object.fromEntries(
|
|
208
|
+
Object.entries(alias || {}).map(([key, value]) => [
|
|
209
|
+
normalizeUtoopackPath(key),
|
|
210
|
+
normalizeUtoopackPath(value)
|
|
211
|
+
])
|
|
212
|
+
);
|
|
213
|
+
const normalizedRootDir = normalizeUtoopackPath(rootDir);
|
|
200
214
|
for (const [key, value] of Object.entries(newAlias)) {
|
|
201
215
|
if (key.endsWith("/*") || value.endsWith("/*") || key.endsWith("/") || value.endsWith("/") || key.endsWith("$")) {
|
|
202
216
|
continue;
|
|
@@ -204,7 +218,9 @@ function getNormalizedAlias(alias, rootDir) {
|
|
|
204
218
|
const ext = (0, import_path.extname)(value);
|
|
205
219
|
if (ext) {
|
|
206
220
|
let isDirectory = false;
|
|
207
|
-
const candidates = [
|
|
221
|
+
const candidates = [
|
|
222
|
+
.../* @__PURE__ */ new Set([value, (0, import_path.resolve)(normalizedRootDir, value)])
|
|
223
|
+
];
|
|
208
224
|
for (const candidate of candidates) {
|
|
209
225
|
try {
|
|
210
226
|
const stat = import_fs.default.statSync(candidate);
|
|
@@ -219,7 +235,7 @@ function getNormalizedAlias(alias, rootDir) {
|
|
|
219
235
|
}
|
|
220
236
|
newAlias[`${key}/*`] = `${value}/*`;
|
|
221
237
|
}
|
|
222
|
-
newAlias[`${
|
|
238
|
+
newAlias[`${normalizedRootDir}/*`] = `${normalizedRootDir}/*`;
|
|
223
239
|
return newAlias;
|
|
224
240
|
}
|
|
225
241
|
function getNormalizedExternals(externals) {
|
|
@@ -374,6 +390,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
374
390
|
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
375
391
|
chainWebpack: opts.chainWebpack,
|
|
376
392
|
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
393
|
+
staticPathPrefix: opts.staticPathPrefix,
|
|
377
394
|
pkg: opts.pkg,
|
|
378
395
|
disableCopy: opts.disableCopy
|
|
379
396
|
});
|
|
@@ -410,6 +427,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
410
427
|
output: {
|
|
411
428
|
clean: opts.clean,
|
|
412
429
|
publicPath: runtimePublicPath ? "runtime" : publicPath || "/",
|
|
430
|
+
assetModuleFilename: getAssetModuleFilename(opts.staticPathPrefix),
|
|
413
431
|
...opts.disableCopy ? { copy: [] } : { copy: ["public"].concat(copy) }
|
|
414
432
|
},
|
|
415
433
|
optimization: {
|
|
@@ -503,6 +521,7 @@ async function getDevUtooPackConfig(opts) {
|
|
|
503
521
|
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
504
522
|
chainWebpack: opts.chainWebpack,
|
|
505
523
|
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
524
|
+
staticPathPrefix: opts.staticPathPrefix,
|
|
506
525
|
// TO avoild bundler webpack add extra entry.
|
|
507
526
|
hmr: false,
|
|
508
527
|
analyze: process.env.ANALYZE
|
|
@@ -545,6 +564,7 @@ async function getDevUtooPackConfig(opts) {
|
|
|
545
564
|
output: {
|
|
546
565
|
clean: opts.clean === void 0 ? true : opts.clean,
|
|
547
566
|
publicPath: runtimePublicPath ? "runtime" : publicPath || "/",
|
|
567
|
+
assetModuleFilename: getAssetModuleFilename(opts.staticPathPrefix),
|
|
548
568
|
...opts.disableCopy ? { copy: [] } : { copy: ["public"].concat(copy) }
|
|
549
569
|
},
|
|
550
570
|
resolve: {
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.57",
|
|
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.8",
|
|
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-
|
|
24
|
-
"@umijs/bundler-
|
|
23
|
+
"@umijs/bundler-webpack": "4.6.57",
|
|
24
|
+
"@umijs/bundler-utils": "4.6.57"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"father": "4.1.5"
|