vite-plugin-blocklet 0.6.7 → 0.6.9
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/index.cjs +14 -9
- package/index.js +1 -6
- package/libs/loading.js +1 -1
- package/libs/meta.js +12 -1
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var vitePluginNodePolyfills = require('vite-plugin-node-polyfills');
|
|
6
|
-
var VitePluginEntryInject = require('vite-plugin-entry-inject');
|
|
7
6
|
var vite = require('vite');
|
|
8
7
|
var semver = require('semver');
|
|
9
8
|
var Mcrypto = require('@ocap/mcrypto');
|
|
@@ -17,7 +16,6 @@ var mri = require('mri');
|
|
|
17
16
|
|
|
18
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
18
|
|
|
20
|
-
var VitePluginEntryInject__default = /*#__PURE__*/_interopDefaultLegacy(VitePluginEntryInject);
|
|
21
19
|
var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
|
|
22
20
|
var Mcrypto__default = /*#__PURE__*/_interopDefaultLegacy(Mcrypto);
|
|
23
21
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
@@ -131,8 +129,19 @@ function createConfigPlugin() {
|
|
|
131
129
|
function createMetaPlugin() {
|
|
132
130
|
return {
|
|
133
131
|
name: 'blocklet:meta',
|
|
134
|
-
transformIndexHtml(html) {
|
|
132
|
+
transformIndexHtml(html, ctx) {
|
|
135
133
|
const tags = [];
|
|
134
|
+
if (ctx?.chunk?.isEntry) {
|
|
135
|
+
let script;
|
|
136
|
+
html = html.replace(new RegExp('<script[^<>]+' + ctx.chunk.fileName + '[^<>]+></script>'), (match) => {
|
|
137
|
+
script = match;
|
|
138
|
+
|
|
139
|
+
return '';
|
|
140
|
+
});
|
|
141
|
+
if (script) {
|
|
142
|
+
html = html.replace('</body>', `${script}</body>`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
136
145
|
// 如果 index.html 中没有设置 title,则自动注入 blocklet.yml 中的 title
|
|
137
146
|
if (!/<title>(.*?)<\/title>/.test(html)) {
|
|
138
147
|
const blockletYamlPath = './blocklet.yml';
|
|
@@ -270,7 +279,7 @@ function generateHtml({ color, image }) {
|
|
|
270
279
|
}
|
|
271
280
|
</style>
|
|
272
281
|
<div class="spinner-wrapper">
|
|
273
|
-
<img src="${image}" width="
|
|
282
|
+
<img src="${image}" width="70" height="70" style="margin-bottom: 16px" />
|
|
274
283
|
<div class="spinner">
|
|
275
284
|
<div class="bounce1"></div>
|
|
276
285
|
<div class="bounce2"></div>
|
|
@@ -364,11 +373,7 @@ function createBlockletPlugin(options = {}) {
|
|
|
364
373
|
disableLoading = false,
|
|
365
374
|
...restOptions
|
|
366
375
|
} = options;
|
|
367
|
-
const plugins = [
|
|
368
|
-
VitePluginEntryInject__default["default"]({
|
|
369
|
-
injectTo: 'body',
|
|
370
|
-
}),
|
|
371
|
-
];
|
|
376
|
+
const plugins = [];
|
|
372
377
|
if (!disableMeta) {
|
|
373
378
|
plugins.push(createMetaPlugin());
|
|
374
379
|
}
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
2
|
-
import VitePluginEntryInject from 'vite-plugin-entry-inject';
|
|
3
2
|
import createHmrPlugin from './libs/hmr.js';
|
|
4
3
|
import createConfigPlugin from './libs/config.js';
|
|
5
4
|
import createMetaPlugin from './libs/meta.js';
|
|
@@ -36,11 +35,7 @@ export function createBlockletPlugin(options = {}) {
|
|
|
36
35
|
disableLoading = false,
|
|
37
36
|
...restOptions
|
|
38
37
|
} = options;
|
|
39
|
-
const plugins = [
|
|
40
|
-
VitePluginEntryInject({
|
|
41
|
-
injectTo: 'body',
|
|
42
|
-
}),
|
|
43
|
-
];
|
|
38
|
+
const plugins = [];
|
|
44
39
|
if (!disableMeta) {
|
|
45
40
|
plugins.push(createMetaPlugin(restOptions));
|
|
46
41
|
}
|
package/libs/loading.js
CHANGED
|
@@ -107,7 +107,7 @@ function generateHtml({ color, image }) {
|
|
|
107
107
|
}
|
|
108
108
|
</style>
|
|
109
109
|
<div class="spinner-wrapper">
|
|
110
|
-
<img src="${image}" width="
|
|
110
|
+
<img src="${image}" width="70" height="70" style="margin-bottom: 16px" />
|
|
111
111
|
<div class="spinner">
|
|
112
112
|
<div class="bounce1"></div>
|
|
113
113
|
<div class="bounce2"></div>
|
package/libs/meta.js
CHANGED
|
@@ -4,8 +4,19 @@ import YAML from 'yaml';
|
|
|
4
4
|
export default function createMetaPlugin() {
|
|
5
5
|
return {
|
|
6
6
|
name: 'blocklet:meta',
|
|
7
|
-
transformIndexHtml(html) {
|
|
7
|
+
transformIndexHtml(html, ctx) {
|
|
8
8
|
const tags = [];
|
|
9
|
+
if (ctx?.chunk?.isEntry) {
|
|
10
|
+
let script;
|
|
11
|
+
html = html.replace(new RegExp('<script[^<>]+' + ctx.chunk.fileName + '[^<>]+></script>'), (match) => {
|
|
12
|
+
script = match;
|
|
13
|
+
|
|
14
|
+
return '';
|
|
15
|
+
});
|
|
16
|
+
if (script) {
|
|
17
|
+
html = html.replace('</body>', `${script}</body>`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
9
20
|
// 如果 index.html 中没有设置 title,则自动注入 blocklet.yml 中的 title
|
|
10
21
|
if (!/<title>(.*?)<\/title>/.test(html)) {
|
|
11
22
|
const blockletYamlPath = './blocklet.yml';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.9",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -27,13 +27,12 @@
|
|
|
27
27
|
"rollup": "^2.79.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@arcblock/did": "^1.18.
|
|
31
|
-
"@ocap/mcrypto": "^1.18.
|
|
32
|
-
"@ocap/util": "^1.18.
|
|
30
|
+
"@arcblock/did": "^1.18.88",
|
|
31
|
+
"@ocap/mcrypto": "^1.18.88",
|
|
32
|
+
"@ocap/util": "^1.18.88",
|
|
33
33
|
"get-port": "^5.1.1",
|
|
34
34
|
"mri": "^1.2.0",
|
|
35
35
|
"semver": "^7.5.4",
|
|
36
|
-
"vite-plugin-entry-inject": "^1.0.2",
|
|
37
36
|
"vite-plugin-node-polyfills": "^0.7.0",
|
|
38
37
|
"yaml": "^2.3.1"
|
|
39
38
|
},
|