@umijs/bundler-vite 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/build.d.ts +0 -0
- package/dist/build.js +118 -94
- package/dist/cli.d.ts +0 -0
- package/dist/cli.js +72 -64
- package/dist/config/config.d.ts +0 -0
- package/dist/config/config.js +70 -30
- package/dist/config/transformer/alias.d.ts +1 -1
- package/dist/config/transformer/alias.js +59 -47
- package/dist/config/transformer/css.d.ts +1 -1
- package/dist/config/transformer/css.js +71 -50
- package/dist/config/transformer/define.d.ts +1 -1
- package/dist/config/transformer/define.js +34 -14
- package/dist/config/transformer/index.d.ts +1 -1
- package/dist/config/transformer/index.js +51 -30
- package/dist/config/transformer/merge.d.ts +1 -1
- package/dist/config/transformer/merge.js +30 -9
- package/dist/config/transformer/optimizeDeps.d.ts +1 -1
- package/dist/config/transformer/optimizeDeps.js +34 -15
- package/dist/config/transformer/react.d.ts +1 -1
- package/dist/config/transformer/react.js +56 -28
- package/dist/config/transformer/rename.d.ts +1 -1
- package/dist/config/transformer/rename.js +53 -40
- package/dist/config/transformer/rollup.d.ts +1 -1
- package/dist/config/transformer/rollup.js +69 -62
- package/dist/config/transformer/target.d.ts +1 -1
- package/dist/config/transformer/target.js +58 -68
- package/dist/dev.d.ts +0 -0
- package/dist/dev.js +55 -31
- package/dist/index.d.ts +0 -0
- package/dist/index.js +19 -17
- package/dist/plugins/autoCSSModule.d.ts +0 -0
- package/dist/plugins/autoCSSModule.js +42 -37
- package/dist/plugins/deleteOutputFiles.d.ts +0 -0
- package/dist/plugins/deleteOutputFiles.js +37 -18
- package/dist/plugins/externals.d.ts +0 -0
- package/dist/plugins/externals.js +40 -21
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +39 -20
- package/dist/plugins/svgr.d.ts +0 -0
- package/dist/plugins/svgr.js +75 -48
- package/dist/schema.d.ts +0 -0
- package/dist/schema.js +67 -44
- package/dist/server/plugins/onHotUpdate.d.ts +0 -0
- package/dist/server/plugins/onHotUpdate.js +33 -10
- package/dist/server/server.d.ts +0 -1
- package/dist/server/server.js +110 -88
- package/dist/types.d.ts +0 -0
- package/dist/types.js +41 -14
- package/package.json +5 -5
package/dist/build.d.ts
CHANGED
|
File without changes
|
package/dist/build.js
CHANGED
|
@@ -1,102 +1,126 @@
|
|
|
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;
|
|
22
|
+
};
|
|
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;
|
|
4
35
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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_fs = __toESM(require("fs"));
|
|
47
|
+
var import_path = __toESM(require("path"));
|
|
48
|
+
var import_vite = require("../compiled/vite");
|
|
49
|
+
var import_config = require("./config/config");
|
|
50
|
+
var import_deleteOutputFiles = __toESM(require("./plugins/deleteOutputFiles"));
|
|
51
|
+
var import_types = require("./types");
|
|
17
52
|
function getUmiTmpDir(entry) {
|
|
18
|
-
|
|
19
|
-
|
|
53
|
+
const mainEntry = Object.values(entry).find((p) => p.includes("/umi.ts"));
|
|
54
|
+
return mainEntry && import_path.default.dirname(mainEntry);
|
|
20
55
|
}
|
|
21
|
-
/**
|
|
22
|
-
* generate temp html entry for vite builder
|
|
23
|
-
* @param cwd project root
|
|
24
|
-
* @param entry umi entry config
|
|
25
|
-
*/
|
|
26
56
|
function generateTempEntry(cwd, entry) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
57
|
+
const umiTmpDir = entry && getUmiTmpDir(entry);
|
|
58
|
+
if (umiTmpDir) {
|
|
59
|
+
const entryTmpDir = import_path.default.join(umiTmpDir, ".bundler-vite-entry");
|
|
60
|
+
import_fs.default.mkdirSync(entryTmpDir);
|
|
61
|
+
return Object.keys(entry).reduce((r, name) => {
|
|
62
|
+
const entryFilePath = import_path.default.join(entryTmpDir, `${name}.html`);
|
|
63
|
+
import_fs.default.writeFileSync(entryFilePath, `<html><head></head><body><script type="module" src="${entry[name]}"><\/script></body></html>`, "utf8");
|
|
64
|
+
return __spreadProps(__spreadValues({}, r), {
|
|
65
|
+
[name]: import_path.default.relative(cwd, entryFilePath)
|
|
66
|
+
});
|
|
67
|
+
}, {});
|
|
68
|
+
}
|
|
40
69
|
}
|
|
41
70
|
async function build(opts) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}),
|
|
86
|
-
],
|
|
87
|
-
}
|
|
88
|
-
: // fallback to vite default entry
|
|
89
|
-
{},
|
|
90
|
-
},
|
|
91
|
-
}, viteUserConfig);
|
|
92
|
-
try {
|
|
93
|
-
result.stats = await (0, vite_1.build)(viteBuildConfig);
|
|
94
|
-
result.stats.extraHtml = extraHtmlPart;
|
|
95
|
-
result.time = +new Date() - startTms;
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
result.err = err;
|
|
71
|
+
let extraHtmlPart;
|
|
72
|
+
const startTms = +new Date();
|
|
73
|
+
const result = {
|
|
74
|
+
isFirstCompile: true,
|
|
75
|
+
time: 0
|
|
76
|
+
};
|
|
77
|
+
const tmpHtmlEntry = generateTempEntry(opts.cwd, opts.entry);
|
|
78
|
+
const viteUserConfig = await (0, import_config.getConfig)({
|
|
79
|
+
cwd: opts.cwd,
|
|
80
|
+
env: import_types.Env.production,
|
|
81
|
+
entry: opts.entry,
|
|
82
|
+
userConfig: opts.config,
|
|
83
|
+
extraBabelPlugins: [
|
|
84
|
+
...opts.beforeBabelPlugins || [],
|
|
85
|
+
...opts.extraBabelPlugins || []
|
|
86
|
+
],
|
|
87
|
+
extraBabelPresets: [
|
|
88
|
+
...opts.beforeBabelPresets || [],
|
|
89
|
+
...opts.extraBabelPresets || []
|
|
90
|
+
],
|
|
91
|
+
modifyViteConfig: opts.modifyViteConfig
|
|
92
|
+
});
|
|
93
|
+
const viteBuildConfig = (0, import_vite.mergeConfig)({
|
|
94
|
+
root: opts.cwd,
|
|
95
|
+
mode: import_types.Env.production,
|
|
96
|
+
build: {
|
|
97
|
+
assetsDir: import_path.default.relative("/", import_path.default.join("/", opts.config.publicPath || "")),
|
|
98
|
+
rollupOptions: tmpHtmlEntry ? {
|
|
99
|
+
input: tmpHtmlEntry,
|
|
100
|
+
plugins: [
|
|
101
|
+
(0, import_deleteOutputFiles.default)(Object.values(tmpHtmlEntry), (file) => {
|
|
102
|
+
if (file.type === "asset") {
|
|
103
|
+
const $ = import_utils.cheerio.load(file.source);
|
|
104
|
+
extraHtmlPart = {
|
|
105
|
+
head: $("head").html(),
|
|
106
|
+
body: $("body").html()
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
} : {}
|
|
99
112
|
}
|
|
100
|
-
|
|
113
|
+
}, viteUserConfig);
|
|
114
|
+
try {
|
|
115
|
+
result.stats = await (0, import_vite.build)(viteBuildConfig);
|
|
116
|
+
result.stats.extraHtml = extraHtmlPart;
|
|
117
|
+
result.time = +new Date() - startTms;
|
|
118
|
+
} catch (err) {
|
|
119
|
+
result.err = err;
|
|
120
|
+
}
|
|
121
|
+
opts.onBuildComplete && opts.onBuildComplete(result);
|
|
101
122
|
}
|
|
102
|
-
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
build
|
|
126
|
+
});
|
package/dist/cli.d.ts
CHANGED
|
File without changes
|
package/dist/cli.js
CHANGED
|
@@ -1,76 +1,84 @@
|
|
|
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
|
-
|
|
39
|
+
import_utils.register.clearFiles();
|
|
40
|
+
if ((0, import_fs.existsSync)(configFile)) {
|
|
41
|
+
config = require(configFile).default;
|
|
30
42
|
}
|
|
31
43
|
Object.assign(config, args);
|
|
32
|
-
if (command ===
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
+
if (command === "build") {
|
|
45
|
+
(async () => {
|
|
46
|
+
process.env.NODE_ENV = "production";
|
|
47
|
+
(0, import_assert.default)(entry, `Build failed: entry not found.`);
|
|
48
|
+
try {
|
|
49
|
+
await (0, import_build.build)({
|
|
50
|
+
config,
|
|
51
|
+
cwd,
|
|
52
|
+
entry: {
|
|
53
|
+
[getEntryKey(entry)]: entry
|
|
44
54
|
}
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
});
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e);
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
60
|
+
} else if (command === "dev") {
|
|
61
|
+
(async () => {
|
|
62
|
+
process.env.NODE_ENV = "development";
|
|
63
|
+
try {
|
|
64
|
+
(0, import_assert.default)(entry, `Build failed: entry not found.`);
|
|
65
|
+
await (0, import_dev.dev)({
|
|
66
|
+
config,
|
|
67
|
+
cwd,
|
|
68
|
+
entry: {
|
|
69
|
+
[getEntryKey(entry)]: entry
|
|
47
70
|
}
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
await (0, dev_1.dev)({
|
|
56
|
-
config,
|
|
57
|
-
cwd,
|
|
58
|
-
entry: {
|
|
59
|
-
[getEntryKey(entry)]: entry,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
console.error(e);
|
|
65
|
-
}
|
|
66
|
-
})();
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
error(`Unsupported command ${command}.`);
|
|
71
|
+
});
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error(e);
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
} else {
|
|
77
|
+
error(`Unsupported command ${command}.`);
|
|
70
78
|
}
|
|
71
79
|
function error(msg) {
|
|
72
|
-
|
|
80
|
+
console.error(import_utils.chalk.red(msg));
|
|
73
81
|
}
|
|
74
82
|
function getEntryKey(path) {
|
|
75
|
-
|
|
83
|
+
return (0, import_path.basename)(path, (0, import_path.extname)(path));
|
|
76
84
|
}
|
package/dist/config/config.d.ts
CHANGED
|
File without changes
|
package/dist/config/config.js
CHANGED
|
@@ -1,33 +1,73 @@
|
|
|
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;
|
|
22
|
+
};
|
|
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 });
|
|
4
27
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
// config.ts
|
|
40
|
+
var config_exports = {};
|
|
41
|
+
__export(config_exports, {
|
|
42
|
+
getConfig: () => getConfig
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(config_exports);
|
|
45
|
+
var import_vite = require("../../compiled/vite");
|
|
46
|
+
var import_plugins = __toESM(require("../plugins"));
|
|
47
|
+
var import_transformer = __toESM(require("./transformer"));
|
|
10
48
|
async function getConfig(opts) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return viteConfig;
|
|
49
|
+
const applyOpts = __spreadProps(__spreadValues({}, opts.userConfig), {
|
|
50
|
+
entry: opts.entry,
|
|
51
|
+
extraBabelPlugins: [
|
|
52
|
+
...opts.extraBabelPlugins || [],
|
|
53
|
+
...opts.userConfig.extraBabelPlugins || []
|
|
54
|
+
],
|
|
55
|
+
extraBabelPresets: [
|
|
56
|
+
...opts.extraBabelPresets || [],
|
|
57
|
+
...opts.userConfig.extraBabelPresets || []
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
const vitePluginsConfig = (0, import_plugins.default)(applyOpts);
|
|
61
|
+
const viteConfigFromUserConfig = (0, import_transformer.default)(applyOpts);
|
|
62
|
+
let viteConfig = (0, import_vite.mergeConfig)(vitePluginsConfig, viteConfigFromUserConfig);
|
|
63
|
+
if (opts.modifyViteConfig) {
|
|
64
|
+
viteConfig = await opts.modifyViteConfig(viteConfig, {
|
|
65
|
+
env: opts.env
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return viteConfig;
|
|
32
69
|
}
|
|
33
|
-
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
getConfig
|
|
73
|
+
});
|
|
@@ -1,50 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
// alias.ts
|
|
20
|
+
var alias_exports = {};
|
|
21
|
+
__export(alias_exports, {
|
|
22
|
+
default: () => alias_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(alias_exports);
|
|
25
|
+
function hoistAlias(alias2) {
|
|
26
|
+
function getFinalReplacement(oAlias, replacement, index) {
|
|
27
|
+
const newAlias = oAlias.slice();
|
|
28
|
+
newAlias.splice(index, 1);
|
|
29
|
+
for (let i = 0; i < newAlias.length; i++) {
|
|
30
|
+
if (newAlias[i].find.test(replacement)) {
|
|
31
|
+
replacement = replacement.replace(newAlias[i].find, newAlias[i].replacement);
|
|
32
|
+
return getFinalReplacement(newAlias, replacement, i);
|
|
33
|
+
}
|
|
16
34
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
return replacement;
|
|
36
|
+
}
|
|
37
|
+
alias2.forEach((rule, index, alias3) => {
|
|
38
|
+
rule.replacement = getFinalReplacement(alias3, rule.replacement, index);
|
|
39
|
+
});
|
|
40
|
+
return alias2;
|
|
21
41
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
alias: [
|
|
29
|
-
// to support less-loader ~ for local deps, refer: https://github.com/vitejs/vite/issues/2185
|
|
30
|
-
{ find: /^~/, replacement: '' },
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
// alias: { foo: bar } foo => bar, foo/hoo => bar/foo
|
|
35
|
-
// alias: { foo$: bar } foo => bar, foo/hoo => foo/hoo
|
|
36
|
-
if (userConfig.alias) {
|
|
37
|
-
const userAlias = Object.entries(userConfig.alias).map(([name, target]) => ({
|
|
38
|
-
// supports webpack suffix $ and less-loader prefix ~
|
|
39
|
-
// example:
|
|
40
|
-
// - dep => ^~?dep(?=\/|$)
|
|
41
|
-
// - dep$ => ^~?dep$
|
|
42
|
-
find: new RegExp(`^~?${name.replace(/(?<!\$)$/, '(?=/|$)')}`),
|
|
43
|
-
replacement: target,
|
|
44
|
-
}));
|
|
45
|
-
const wholeAlias = config.resolve.alias;
|
|
46
|
-
wholeAlias.unshift(...userAlias);
|
|
47
|
-
config.resolve.alias = hoistAlias(wholeAlias);
|
|
42
|
+
var alias_default = function alias(userConfig) {
|
|
43
|
+
const config = {
|
|
44
|
+
resolve: {
|
|
45
|
+
alias: [
|
|
46
|
+
{ find: /^~/, replacement: "" }
|
|
47
|
+
]
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
};
|
|
50
|
+
if (userConfig.alias) {
|
|
51
|
+
const userAlias = Object.entries(userConfig.alias).map(([name, target]) => ({
|
|
52
|
+
find: new RegExp(`^~?${name.replace(/(?<!\$)$/, "(?=/|$)")}`),
|
|
53
|
+
replacement: target
|
|
54
|
+
}));
|
|
55
|
+
const wholeAlias = config.resolve.alias;
|
|
56
|
+
wholeAlias.unshift(...userAlias);
|
|
57
|
+
config.resolve.alias = hoistAlias(wholeAlias);
|
|
58
|
+
}
|
|
59
|
+
return config;
|
|
60
|
+
};
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IConfigProcessor } from '.';
|
|
2
2
|
export declare function getBrowserlist(targets: Record<string, string | boolean>): string | string[];
|
|
3
|
+
declare const _default: IConfigProcessor;
|
|
3
4
|
/**
|
|
4
5
|
* transform umi css pre-processor configs to vite postcss config
|
|
5
6
|
* @note include configs:
|
|
@@ -10,5 +11,4 @@ export declare function getBrowserlist(targets: Record<string, string | boolean>
|
|
|
10
11
|
* - lessLoader
|
|
11
12
|
* - theme
|
|
12
13
|
*/
|
|
13
|
-
declare const _default: IConfigProcessor;
|
|
14
14
|
export default _default;
|