@shuvi/toolpack 1.0.52 → 1.0.53
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/lib/webpack/config/base.js +31 -1
- package/package.json +4 -4
|
@@ -192,7 +192,16 @@ function baseWebpackChain({ dev, outputDir, lightningCss, compiler, projectRoot,
|
|
|
192
192
|
// @ts-ignore
|
|
193
193
|
.type('asset/resource')
|
|
194
194
|
.set('generator', {
|
|
195
|
-
filename:
|
|
195
|
+
filename: (pathData) => {
|
|
196
|
+
// Check if a string is a base64 data URI
|
|
197
|
+
if (pathData.filename && isValidBase64DataURL(pathData.filename)) {
|
|
198
|
+
// Handle base64 string case, [name] is empty
|
|
199
|
+
return `static/media/base64.[hash:8][ext]`;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
return `static/media/[name].[hash:8][ext]`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
196
205
|
});
|
|
197
206
|
// .use('file-loader')
|
|
198
207
|
// .loader(require.resolve('file-loader'))
|
|
@@ -260,3 +269,24 @@ function baseWebpackChain({ dev, outputDir, lightningCss, compiler, projectRoot,
|
|
|
260
269
|
return config;
|
|
261
270
|
}
|
|
262
271
|
exports.baseWebpackChain = baseWebpackChain;
|
|
272
|
+
function isValidBase64DataURL(input) {
|
|
273
|
+
// Check if input starts with the data URI scheme
|
|
274
|
+
if (!input.startsWith('data:')) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
// Split the data URI into metadata and data parts
|
|
278
|
+
const parts = input.split(',');
|
|
279
|
+
if (parts.length !== 2) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
const metadata = parts[0];
|
|
283
|
+
const data = parts[1];
|
|
284
|
+
// Check if the metadata contains 'base64'
|
|
285
|
+
if (!metadata.includes('base64')) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
// Regular expression to validate Base64 string
|
|
289
|
+
const base64Regex = /^[A-Za-z0-9+/]+[=]{0,2}$/;
|
|
290
|
+
// Validate Base64 data
|
|
291
|
+
return base64Regex.test(data);
|
|
292
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/toolpack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">= 16.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@shuvi/compiler": "1.0.
|
|
23
|
+
"@shuvi/compiler": "1.0.53",
|
|
24
24
|
"@babel/core": "7.12.10",
|
|
25
25
|
"@babel/plugin-proposal-class-properties": "7.12.1",
|
|
26
26
|
"@babel/plugin-proposal-nullish-coalescing-operator": "7.10.1",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@babel/preset-typescript": "7.12.7",
|
|
36
36
|
"@babel/runtime": "7.12.5",
|
|
37
37
|
"lightningcss": "1.19.0",
|
|
38
|
-
"@shuvi/shared": "1.0.
|
|
39
|
-
"@shuvi/utils": "1.0.
|
|
38
|
+
"@shuvi/shared": "1.0.53",
|
|
39
|
+
"@shuvi/utils": "1.0.53",
|
|
40
40
|
"babel-loader": "8.2.2",
|
|
41
41
|
"babel-plugin-syntax-jsx": "6.18.0",
|
|
42
42
|
"babel-plugin-transform-define": "2.0.0",
|