@umijs/bundler-webpack 4.0.5 → 4.0.8
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 → client}/client/client.d.ts +0 -0
- package/client/client/client.js +172 -192
- package/client/constants.d.ts +15 -0
- package/client/constants.js +28 -19
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +68 -86
- package/dist/build.d.ts +1 -1
- package/dist/build.js +105 -61
- package/dist/cli.js +77 -69
- package/dist/config/_sampleFeature.js +33 -9
- package/dist/config/assetRules.js +45 -36
- package/dist/config/bundleAnalyzerPlugin.js +39 -17
- package/dist/config/compressPlugin.js +113 -95
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +204 -215
- package/dist/config/copyPlugin.js +58 -33
- package/dist/config/cssRules.js +136 -131
- package/dist/config/definePlugin.d.ts +1 -0
- package/dist/config/definePlugin.js +71 -31
- package/dist/config/detectDeadCode.js +120 -108
- package/dist/config/detectDeadCodePlugin.js +78 -63
- package/dist/config/fastRefreshPlugin.js +39 -20
- package/dist/config/forkTSCheckerPlugin.js +38 -19
- package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
- package/dist/config/ignorePlugin.js +38 -14
- package/dist/config/javaScriptRules.js +146 -173
- package/dist/config/manifestPlugin.js +51 -15
- package/dist/config/miniCSSExtractPlugin.js +42 -22
- package/dist/config/nodePolyfill.js +65 -26
- package/dist/config/nodePrefixPlugin.js +36 -12
- package/dist/config/progressPlugin.js +37 -13
- package/dist/config/purgecssWebpackPlugin.js +41 -19
- package/dist/config/speedMeasureWebpackPlugin.js +41 -20
- package/dist/config/ssrPlugin.js +83 -63
- package/dist/config/svgRules.js +74 -46
- package/dist/constants.js +57 -22
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +170 -129
- package/dist/index.d.ts +0 -2
- package/dist/index.js +22 -35
- package/dist/loader/svgr.js +73 -54
- package/dist/loader/swc.js +110 -69
- package/dist/parcelCSS.d.ts +2 -0
- package/dist/parcelCSS.js +32 -0
- package/dist/plugins/ProgressPlugin.js +66 -43
- package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
- package/dist/plugins/_SamplePlugin.js +39 -14
- package/dist/requireHook.js +37 -27
- package/dist/schema.js +119 -95
- package/dist/server/server.d.ts +0 -1
- package/dist/server/server.js +214 -184
- package/dist/server/ws.d.ts +0 -2
- package/dist/server/ws.js +63 -38
- package/dist/swcPlugins/autoCSSModules.js +50 -31
- package/dist/swcPlugins/changeImportFromString.js +31 -9
- package/dist/swcPlugins/lockCoreJS.js +44 -20
- package/dist/types.js +61 -30
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +63 -39
- package/dist/utils/formatWebpackMessages.js +93 -91
- package/dist/utils/getEsBuildTarget.js +32 -10
- package/package.json +9 -11
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
- package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
- package/dist/client/client.js +0 -245
package/dist/build.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ declare type IOpts = {
|
|
|
15
15
|
extraBabelPlugins?: any[];
|
|
16
16
|
extraBabelPresets?: any[];
|
|
17
17
|
clean?: boolean;
|
|
18
|
-
} & Pick<IConfigOpts, 'cache'>;
|
|
18
|
+
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
|
|
19
19
|
export declare function build(opts: IOpts): Promise<webpack.Stats>;
|
|
20
20
|
export {};
|
package/dist/build.js
CHANGED
|
@@ -1,66 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
4
22
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
|
|
39
|
+
// build.ts
|
|
40
|
+
var build_exports = {};
|
|
41
|
+
__export(build_exports, {
|
|
42
|
+
build: () => build
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(build_exports);
|
|
45
|
+
var import_utils = require("@umijs/utils");
|
|
46
|
+
var import_path = require("path");
|
|
47
|
+
var import_webpack = __toESM(require("../compiled/webpack"));
|
|
48
|
+
var import_config = require("./config/config");
|
|
49
|
+
var import_types = require("./types");
|
|
11
50
|
async function build(opts) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
|
|
52
|
+
const webpackConfig = await (0, import_config.getConfig)({
|
|
53
|
+
cwd: opts.cwd,
|
|
54
|
+
rootDir: opts.rootDir,
|
|
55
|
+
env: import_types.Env.production,
|
|
56
|
+
entry: opts.entry,
|
|
57
|
+
userConfig: opts.config,
|
|
58
|
+
analyze: process.env.ANALYZE,
|
|
59
|
+
babelPreset: opts.babelPreset,
|
|
60
|
+
extraBabelPlugins: [
|
|
61
|
+
...opts.beforeBabelPlugins || [],
|
|
62
|
+
...opts.extraBabelPlugins || []
|
|
63
|
+
],
|
|
64
|
+
extraBabelPresets: [
|
|
65
|
+
...opts.beforeBabelPresets || [],
|
|
66
|
+
...opts.extraBabelPresets || []
|
|
67
|
+
],
|
|
68
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
69
|
+
chainWebpack: opts.chainWebpack,
|
|
70
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
71
|
+
cache: opts.cache ? __spreadProps(__spreadValues({}, opts.cache), {
|
|
72
|
+
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "bundler-webpack")
|
|
73
|
+
}) : void 0,
|
|
74
|
+
pkg: opts.pkg
|
|
75
|
+
});
|
|
76
|
+
let isFirstCompile = true;
|
|
77
|
+
return new Promise((resolve2, reject) => {
|
|
78
|
+
if (opts.clean) {
|
|
79
|
+
import_utils.rimraf.sync(webpackConfig.output.path);
|
|
80
|
+
}
|
|
81
|
+
const compiler = (0, import_webpack.default)(webpackConfig);
|
|
82
|
+
compiler.run((err, stats) => {
|
|
83
|
+
var _a;
|
|
84
|
+
(_a = opts.onBuildComplete) == null ? void 0 : _a.call(opts, {
|
|
85
|
+
err,
|
|
86
|
+
stats,
|
|
87
|
+
isFirstCompile,
|
|
88
|
+
time: stats ? stats.endTime - stats.startTime : null
|
|
89
|
+
});
|
|
90
|
+
isFirstCompile = false;
|
|
91
|
+
if (err || (stats == null ? void 0 : stats.hasErrors())) {
|
|
92
|
+
if (err) {
|
|
93
|
+
reject(err);
|
|
94
|
+
}
|
|
95
|
+
if (stats) {
|
|
96
|
+
const errorMsg = stats.toString("errors-only");
|
|
97
|
+
reject(new Error(errorMsg));
|
|
37
98
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
stats,
|
|
44
|
-
isFirstCompile,
|
|
45
|
-
time: stats ? stats.endTime - stats.startTime : null,
|
|
46
|
-
});
|
|
47
|
-
isFirstCompile = false;
|
|
48
|
-
if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
|
|
49
|
-
if (err) {
|
|
50
|
-
// console.error(err);
|
|
51
|
-
reject(err);
|
|
52
|
-
}
|
|
53
|
-
if (stats) {
|
|
54
|
-
const errorMsg = stats.toString('errors-only');
|
|
55
|
-
// console.error(errorMsg);
|
|
56
|
-
reject(new Error(errorMsg));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
resolve(stats);
|
|
61
|
-
}
|
|
62
|
-
compiler.close(() => { });
|
|
63
|
-
});
|
|
99
|
+
} else {
|
|
100
|
+
resolve2(stats);
|
|
101
|
+
}
|
|
102
|
+
compiler.close(() => {
|
|
103
|
+
});
|
|
64
104
|
});
|
|
105
|
+
});
|
|
65
106
|
}
|
|
66
|
-
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
build
|
|
110
|
+
});
|
package/dist/cli.js
CHANGED
|
@@ -1,81 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
4
14
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
16
|
+
|
|
17
|
+
// cli.ts
|
|
18
|
+
var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
19
|
+
var import_utils = require("@umijs/utils");
|
|
20
|
+
var import_assert = __toESM(require("assert"));
|
|
21
|
+
var import_fs = require("fs");
|
|
22
|
+
var import_path = require("path");
|
|
23
|
+
var import_build = require("./build");
|
|
24
|
+
var import_dev = require("./dev");
|
|
25
|
+
var args = (0, import_utils.yParser)(process.argv.slice(2), {});
|
|
26
|
+
var command = args._[0];
|
|
27
|
+
var cwd = process.cwd();
|
|
28
|
+
var entry = (0, import_utils.tryPaths)([
|
|
29
|
+
(0, import_path.join)(cwd, "src/index.tsx"),
|
|
30
|
+
(0, import_path.join)(cwd, "src/index.ts"),
|
|
31
|
+
(0, import_path.join)(cwd, "index.tsx"),
|
|
32
|
+
(0, import_path.join)(cwd, "index.ts")
|
|
21
33
|
]);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
var config = {};
|
|
35
|
+
var configFile = (0, import_path.join)(cwd, args.config || "config.ts");
|
|
36
|
+
import_utils.register.register({
|
|
37
|
+
implementor: import_esbuild.default
|
|
26
38
|
});
|
|
27
|
-
|
|
28
|
-
if ((0,
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
import_utils.register.clearFiles();
|
|
40
|
+
if ((0, import_fs.existsSync)(configFile)) {
|
|
41
|
+
require("./requireHook");
|
|
42
|
+
config = require(configFile).default;
|
|
31
43
|
}
|
|
32
44
|
Object.assign(config, args);
|
|
33
|
-
if (command ===
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
+
if (command === "build") {
|
|
46
|
+
(async () => {
|
|
47
|
+
process.env.NODE_ENV = "production";
|
|
48
|
+
(0, import_assert.default)(entry, `Build failed: entry not found.`);
|
|
49
|
+
try {
|
|
50
|
+
await (0, import_build.build)({
|
|
51
|
+
config,
|
|
52
|
+
cwd,
|
|
53
|
+
entry: {
|
|
54
|
+
[getEntryKey(entry)]: entry
|
|
45
55
|
}
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
});
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
})();
|
|
61
|
+
} else if (command === "dev") {
|
|
62
|
+
(async () => {
|
|
63
|
+
process.env.NODE_ENV = "development";
|
|
64
|
+
try {
|
|
65
|
+
(0, import_assert.default)(entry, `Build failed: entry not found.`);
|
|
66
|
+
await (0, import_dev.dev)({
|
|
67
|
+
config,
|
|
68
|
+
cwd,
|
|
69
|
+
port: process.env.PORT,
|
|
70
|
+
entry: {
|
|
71
|
+
[getEntryKey(entry)]: entry
|
|
72
|
+
},
|
|
73
|
+
cache: {
|
|
74
|
+
buildDependencies: [].filter(Boolean)
|
|
48
75
|
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
await (0, dev_1.dev)({
|
|
57
|
-
config,
|
|
58
|
-
cwd,
|
|
59
|
-
port: process.env.PORT,
|
|
60
|
-
entry: {
|
|
61
|
-
[getEntryKey(entry)]: entry,
|
|
62
|
-
},
|
|
63
|
-
cache: {
|
|
64
|
-
buildDependencies: [].filter(Boolean),
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
console.error(e);
|
|
70
|
-
}
|
|
71
|
-
})();
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
error(`Unsupported command ${command}.`);
|
|
76
|
+
});
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.error(e);
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
} else {
|
|
82
|
+
error(`Unsupported command ${command}.`);
|
|
75
83
|
}
|
|
76
84
|
function error(msg) {
|
|
77
|
-
|
|
85
|
+
console.error(import_utils.chalk.red(msg));
|
|
78
86
|
}
|
|
79
87
|
function getEntryKey(path) {
|
|
80
|
-
|
|
88
|
+
return (0, import_path.basename)(path, (0, import_path.extname)(path));
|
|
81
89
|
}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// _sampleFeature.ts
|
|
20
|
+
var sampleFeature_exports = {};
|
|
21
|
+
__export(sampleFeature_exports, {
|
|
22
|
+
addSampleFeature: () => addSampleFeature
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(sampleFeature_exports);
|
|
4
25
|
async function addSampleFeature(opts) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
const { config, userConfig, cwd, env } = opts;
|
|
27
|
+
config;
|
|
28
|
+
userConfig;
|
|
29
|
+
cwd;
|
|
30
|
+
env;
|
|
10
31
|
}
|
|
11
|
-
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
addSampleFeature
|
|
35
|
+
});
|
|
@@ -1,39 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// assetRules.ts
|
|
20
|
+
var assetRules_exports = {};
|
|
21
|
+
__export(assetRules_exports, {
|
|
22
|
+
addAssetRules: () => addAssetRules
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(assetRules_exports);
|
|
4
25
|
async function addAssetRules(opts) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.type('asset')
|
|
12
|
-
.mimetype('image/avif')
|
|
13
|
-
.parser({
|
|
14
|
-
dataUrlCondition: {
|
|
15
|
-
maxSize: inlineLimit,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
rule
|
|
19
|
-
.oneOf('image')
|
|
20
|
-
.test(/\.(bmp|gif|jpg|jpeg|png)$/)
|
|
21
|
-
.type('asset')
|
|
22
|
-
.parser({
|
|
23
|
-
dataUrlCondition: {
|
|
24
|
-
maxSize: inlineLimit,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
const fallback = rule
|
|
28
|
-
.oneOf('fallback')
|
|
29
|
-
.exclude.add(/^$/) /* handle data: resources */
|
|
30
|
-
.add(/\.(js|mjs|jsx|ts|tsx)$/)
|
|
31
|
-
.add(/\.(css|less|sass|scss|stylus)$/)
|
|
32
|
-
.add(/\.html$/)
|
|
33
|
-
.add(/\.json$/);
|
|
34
|
-
if (userConfig.mdx) {
|
|
35
|
-
fallback.add(/\.mdx?$/);
|
|
26
|
+
const { config, userConfig } = opts;
|
|
27
|
+
const inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
|
|
28
|
+
const rule = config.module.rule("asset");
|
|
29
|
+
rule.oneOf("avif").test(/\.avif$/).type("asset").mimetype("image/avif").parser({
|
|
30
|
+
dataUrlCondition: {
|
|
31
|
+
maxSize: inlineLimit
|
|
36
32
|
}
|
|
37
|
-
|
|
33
|
+
});
|
|
34
|
+
rule.oneOf("image").test(/\.(bmp|gif|jpg|jpeg|png)$/).type("asset").parser({
|
|
35
|
+
dataUrlCondition: {
|
|
36
|
+
maxSize: inlineLimit
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const fallback = rule.oneOf("fallback").exclude.add(/^$/).add(/\.(js|mjs|jsx|ts|tsx)$/).add(/\.(css|less|sass|scss|stylus)$/).add(/\.html$/).add(/\.json$/);
|
|
40
|
+
if (userConfig.mdx) {
|
|
41
|
+
fallback.add(/\.mdx?$/);
|
|
42
|
+
}
|
|
43
|
+
fallback.end().type("asset/resource");
|
|
38
44
|
}
|
|
39
|
-
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
addAssetRules
|
|
48
|
+
});
|
|
@@ -1,19 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// bundleAnalyzerPlugin.ts
|
|
20
|
+
var bundleAnalyzerPlugin_exports = {};
|
|
21
|
+
__export(bundleAnalyzerPlugin_exports, {
|
|
22
|
+
addBundleAnalyzerPlugin: () => addBundleAnalyzerPlugin
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(bundleAnalyzerPlugin_exports);
|
|
25
|
+
var import_webpack_bundle_analyzer = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
|
|
6
26
|
async function addBundleAnalyzerPlugin(opts) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
27
|
+
const { config } = opts;
|
|
28
|
+
config.plugin("webpack-bundle-analyzer").use(import_webpack_bundle_analyzer.BundleAnalyzerPlugin, [
|
|
29
|
+
{
|
|
30
|
+
analyzerMode: "server",
|
|
31
|
+
analyzerPort: process.env.ANALYZE_PORT || 8888,
|
|
32
|
+
openAnalyzer: false,
|
|
33
|
+
logLevel: "info",
|
|
34
|
+
defaultSizes: "parsed"
|
|
35
|
+
}
|
|
36
|
+
]);
|
|
18
37
|
}
|
|
19
|
-
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
addBundleAnalyzerPlugin
|
|
41
|
+
});
|