vite-plugin-blocklet 0.4.19 → 0.4.20
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/index.js +4 -4
- package/libs/config.js +14 -1
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import createHmrPlugin from './libs/hmr';
|
|
2
|
-
import createConfigPlugin from './libs/config';
|
|
3
|
-
import createMetaPlugin from './libs/meta';
|
|
4
|
-
import { isInBlocklet } from './libs/utils';
|
|
1
|
+
import createHmrPlugin from './libs/hmr.js';
|
|
2
|
+
import createConfigPlugin from './libs/config.js';
|
|
3
|
+
import createMetaPlugin from './libs/meta.js';
|
|
4
|
+
import { isInBlocklet } from './libs/utils.js';
|
|
5
5
|
|
|
6
6
|
export function createBlockletPlugin(options = {}) {
|
|
7
7
|
const { disableConfig = false, disableMeta = false, disableHmr = false } = options;
|
package/libs/config.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import YAML from 'yaml';
|
|
3
|
-
import { toBlockletDid } from './utils';
|
|
4
|
+
import { toBlockletDid, isInBlocklet } from './utils.js';
|
|
4
5
|
|
|
5
6
|
export default function createConfigPlugin() {
|
|
6
7
|
return {
|
|
7
8
|
name: 'blocklet:config',
|
|
9
|
+
configureServer(server) {
|
|
10
|
+
if (isInBlocklet) {
|
|
11
|
+
server.middlewares.use((req, res, next) => {
|
|
12
|
+
const prefix = req.headers['x-path-prefix'] || '/';
|
|
13
|
+
// blocklet server 会把设置的 base 从请求 url 中移除,所以需要再加回 base
|
|
14
|
+
if (!req.url.startsWith(prefix)) {
|
|
15
|
+
req.url = path.join(prefix || '/', req.url);
|
|
16
|
+
}
|
|
17
|
+
return next();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
},
|
|
8
21
|
config(config, { command }) {
|
|
9
22
|
if (command === 'serve') {
|
|
10
23
|
const targetConfig = {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.20",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"rollup": "^2.76.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@arcblock/did": "^1.17.
|
|
21
|
-
"@ocap/mcrypto": "^1.17.
|
|
22
|
-
"@ocap/util": "^1.17.
|
|
20
|
+
"@arcblock/did": "^1.17.5",
|
|
21
|
+
"@ocap/mcrypto": "^1.17.5",
|
|
22
|
+
"@ocap/util": "^1.17.5",
|
|
23
23
|
"yaml": "^2.1.1"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|