@shuvi/toolpack 1.0.51 → 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 +39 -4
- package/package.json +5 -6
|
@@ -189,11 +189,25 @@ function baseWebpackChain({ dev, outputDir, lightningCss, compiler, projectRoot,
|
|
|
189
189
|
.oneOf('media')
|
|
190
190
|
.exclude.merge([/\.(tsx|ts|js|cjs|mjs|jsx)$/, /\.html$/, /\.json$/])
|
|
191
191
|
.end()
|
|
192
|
-
|
|
193
|
-
.
|
|
194
|
-
.
|
|
195
|
-
|
|
192
|
+
// @ts-ignore
|
|
193
|
+
.type('asset/resource')
|
|
194
|
+
.set('generator', {
|
|
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
|
});
|
|
206
|
+
// .use('file-loader')
|
|
207
|
+
// .loader(require.resolve('file-loader'))
|
|
208
|
+
// .options({
|
|
209
|
+
// name: 'static/media/[name].[hash:8].[ext]'
|
|
210
|
+
// });
|
|
197
211
|
config.plugin('private/ignore-plugin').use(webpack_1.default.IgnorePlugin, [
|
|
198
212
|
{
|
|
199
213
|
resourceRegExp: /^\.\/locale$/,
|
|
@@ -255,3 +269,24 @@ function baseWebpackChain({ dev, outputDir, lightningCss, compiler, projectRoot,
|
|
|
255
269
|
return config;
|
|
256
270
|
}
|
|
257
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",
|
|
@@ -50,11 +50,10 @@
|
|
|
50
50
|
"es-module-lexer": "0.10.5",
|
|
51
51
|
"esbuild": "0.14.38",
|
|
52
52
|
"esbuild-loader": "2.19.0",
|
|
53
|
-
"file-loader": "6.2.0",
|
|
54
53
|
"fork-ts-checker-webpack-plugin": "6.0.8",
|
|
55
54
|
"fs-extra": "9.0.1",
|
|
56
55
|
"ignore-loader": "0.1.2",
|
|
57
|
-
"loader-utils": "
|
|
56
|
+
"loader-utils": "3.0.0",
|
|
58
57
|
"mini-css-extract-plugin": "1.3.9",
|
|
59
58
|
"mrmime": "1.0.0",
|
|
60
59
|
"path-browserify": "1.0.1",
|