@umijs/bundler-utoopack 4.6.8 → 4.6.10
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 +31 -0
- package/package.json +4 -4
package/dist/config.js
CHANGED
|
@@ -27,6 +27,27 @@ var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
|
27
27
|
var import_utils = require("@umijs/utils");
|
|
28
28
|
var import_pack = require("@utoo/pack");
|
|
29
29
|
var import_path = require("path");
|
|
30
|
+
function convertProcessEnvForUtoopack(webpackConfig) {
|
|
31
|
+
var _a;
|
|
32
|
+
let processEnvForUtoopack = {};
|
|
33
|
+
if (webpackConfig.plugins) {
|
|
34
|
+
const definePlugin = webpackConfig.plugins.find(
|
|
35
|
+
(plugin) => plugin.constructor.name === "DefinePlugin"
|
|
36
|
+
);
|
|
37
|
+
if ((_a = definePlugin == null ? void 0 : definePlugin.definitions) == null ? void 0 : _a["process.env"]) {
|
|
38
|
+
for (const [key, value] of Object.entries(
|
|
39
|
+
definePlugin.definitions["process.env"]
|
|
40
|
+
)) {
|
|
41
|
+
if (typeof value === "string" && value.startsWith('"') && value.endsWith('"')) {
|
|
42
|
+
processEnvForUtoopack[key] = JSON.parse(value);
|
|
43
|
+
} else {
|
|
44
|
+
processEnvForUtoopack[key] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return processEnvForUtoopack;
|
|
50
|
+
}
|
|
30
51
|
function getModularizeImports(extraBabelPlugins) {
|
|
31
52
|
return extraBabelPlugins.filter((p) => /^import$|babel-plugin-import/.test(p[0])).reduce(
|
|
32
53
|
(acc, [_, v]) => {
|
|
@@ -133,6 +154,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
133
154
|
...opts.config.extraBabelPlugins || []
|
|
134
155
|
];
|
|
135
156
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
157
|
+
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
136
158
|
const {
|
|
137
159
|
publicPath,
|
|
138
160
|
runtimePublicPath,
|
|
@@ -167,6 +189,10 @@ async function getProdUtooPackConfig(opts) {
|
|
|
167
189
|
},
|
|
168
190
|
sass: opts.config.sassLoader ?? void 0
|
|
169
191
|
},
|
|
192
|
+
// Override process.env for utoopack format
|
|
193
|
+
define: {
|
|
194
|
+
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
195
|
+
},
|
|
170
196
|
nodePolyfill: true,
|
|
171
197
|
externals: getNormalizedExternals(userExternals)
|
|
172
198
|
},
|
|
@@ -208,6 +234,7 @@ async function getDevUtooPackConfig(opts) {
|
|
|
208
234
|
...opts.config.extraBabelPlugins || []
|
|
209
235
|
];
|
|
210
236
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
237
|
+
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
211
238
|
const {
|
|
212
239
|
publicPath,
|
|
213
240
|
runtimePublicPath,
|
|
@@ -242,6 +269,10 @@ async function getDevUtooPackConfig(opts) {
|
|
|
242
269
|
},
|
|
243
270
|
sass: opts.config.sassLoader ?? void 0
|
|
244
271
|
},
|
|
272
|
+
// Override process.env for utoopack format
|
|
273
|
+
define: {
|
|
274
|
+
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
275
|
+
},
|
|
245
276
|
nodePolyfill: true,
|
|
246
277
|
externals: getNormalizedExternals(userExternals)
|
|
247
278
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.10",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@utoo/pack": "1.1.
|
|
11
|
+
"@utoo/pack": "1.1.2",
|
|
12
12
|
"compression": "^1.7.4",
|
|
13
13
|
"connect-history-api-fallback": "^2.0.0",
|
|
14
14
|
"cors": "^2.8.5",
|
|
15
15
|
"express": "^4.18.2",
|
|
16
16
|
"express-http-proxy": "^2.1.1",
|
|
17
|
-
"@umijs/bundler-utils": "4.6.
|
|
18
|
-
"@umijs/bundler-webpack": "4.6.
|
|
17
|
+
"@umijs/bundler-utils": "4.6.10",
|
|
18
|
+
"@umijs/bundler-webpack": "4.6.10"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"father": "4.1.5"
|