create-blocklet 0.4.70 → 0.4.72
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/common/{_editorconfig → .editorconfig} +0 -0
- package/common/{_prettierrc → .prettierrc} +0 -0
- package/index.js +7 -17
- package/package.json +1 -1
- package/templates/react-dapp/.env +1 -1
- package/templates/react-dapp/api/index.js +1 -1
- package/templates/react-dapp/blocklet.yml +2 -2
- package/templates/react-dapp/index.html +16 -0
- package/templates/react-dapp/package.json +8 -5
- package/templates/react-dapp/src/index.jsx +1 -1
- package/templates/react-dapp/vite.config.js +36 -0
- package/templates/react-gun-dapp/.env +1 -1
- package/templates/react-gun-dapp/api/index.js +1 -1
- package/templates/react-gun-dapp/blocklet.yml +2 -2
- package/templates/react-gun-dapp/index.html +16 -0
- package/templates/react-gun-dapp/package.json +8 -5
- package/templates/react-gun-dapp/src/index.jsx +1 -1
- package/templates/react-gun-dapp/src/pages/home.jsx +1 -1
- package/templates/react-gun-dapp/vite.config.js +41 -0
- package/templates/react-static/.env +1 -1
- package/templates/react-static/blocklet.yml +1 -1
- package/templates/react-static/index.html +16 -0
- package/templates/react-static/package.json +9 -5
- package/templates/react-static/src/index.jsx +1 -1
- package/templates/react-static/vite.config.js +26 -0
- package/templates/solidjs-dapp/package.json +1 -1
- package/templates/solidjs-static/package.json +1 -1
- package/templates/svelte-dapp/package.json +1 -1
- package/templates/svelte-static/package.json +1 -1
- package/templates/vue-dapp/package.json +1 -1
- package/templates/vue-dapp/vite.config.js +5 -1
- package/templates/vue-static/package.json +1 -1
- package/templates/vue2-dapp/vue.config.js +4 -4
- package/common/_gitignore +0 -28
- package/common/_npmrc +0 -3
- package/templates/react-dapp/craco.config.js +0 -39
- package/templates/react-dapp/public/index.html +0 -35
- package/templates/react-gun-dapp/craco.config.js +0 -41
- package/templates/react-gun-dapp/public/index.html +0 -35
- package/templates/react-static/craco.config.js +0 -28
- package/templates/react-static/public/index.html +0 -35
|
File without changes
|
|
File without changes
|
package/index.js
CHANGED
|
@@ -16,7 +16,6 @@ import { checkServerInstalled, checkServerRunning, checkSatisfiedVersion, getSer
|
|
|
16
16
|
import { toBlockletDid } from './lib/did.js';
|
|
17
17
|
import { initGitRepo } from './lib/git.js';
|
|
18
18
|
import {
|
|
19
|
-
copy,
|
|
20
19
|
emptyDir,
|
|
21
20
|
isEmpty,
|
|
22
21
|
isValidPackageName,
|
|
@@ -115,12 +114,7 @@ const templates = [
|
|
|
115
114
|
},
|
|
116
115
|
];
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
_gitignore: '.gitignore',
|
|
120
|
-
_npmrc: '.npmrc',
|
|
121
|
-
_editorconfig: '.editorconfig',
|
|
122
|
-
_prettierrc: '.prettierrc',
|
|
123
|
-
};
|
|
117
|
+
|
|
124
118
|
|
|
125
119
|
async function init() {
|
|
126
120
|
const { version } = await fs.readJSONSync(path.resolve(__dirname, 'package.json'));
|
|
@@ -266,7 +260,7 @@ async function init() {
|
|
|
266
260
|
if (mainBlocklet) {
|
|
267
261
|
await checkLerna();
|
|
268
262
|
await checkYarn();
|
|
269
|
-
|
|
263
|
+
fs.copySync(path.join(__dirname, 'templates', 'monorepo'), root);
|
|
270
264
|
}
|
|
271
265
|
|
|
272
266
|
for (const templateName of templateNames) {
|
|
@@ -279,7 +273,7 @@ async function init() {
|
|
|
279
273
|
const commonFiles = fs.readdirSync(commonDir);
|
|
280
274
|
for (const file of commonFiles) {
|
|
281
275
|
// 如果选择多个模板,每个子 package 中 只会包含必要的 文件
|
|
282
|
-
if (mainBlocklet && !['screenshots', 'public', 'logo.png', '
|
|
276
|
+
if (mainBlocklet && !['screenshots', 'public', 'logo.png', '.prettierrc'].includes(file)) {
|
|
283
277
|
continue;
|
|
284
278
|
}
|
|
285
279
|
// xmark 相关的模板不添加 .husky
|
|
@@ -287,11 +281,9 @@ async function init() {
|
|
|
287
281
|
// eslint-disable-next-line no-continue
|
|
288
282
|
continue;
|
|
289
283
|
}
|
|
290
|
-
const targetPath =
|
|
291
|
-
? path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', renameFiles[file])
|
|
292
|
-
: path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', file);
|
|
284
|
+
const targetPath = path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', file);
|
|
293
285
|
|
|
294
|
-
|
|
286
|
+
fs.copySync(path.join(commonDir, file), targetPath);
|
|
295
287
|
}
|
|
296
288
|
})();
|
|
297
289
|
|
|
@@ -518,13 +510,11 @@ async function init() {
|
|
|
518
510
|
|
|
519
511
|
// inside functions
|
|
520
512
|
function write(file, content, templateDir, templateName) {
|
|
521
|
-
const targetPath =
|
|
522
|
-
? path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', renameFiles[file])
|
|
523
|
-
: path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', file);
|
|
513
|
+
const targetPath = path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', file);
|
|
524
514
|
if (content) {
|
|
525
515
|
fs.writeFileSync(targetPath, content);
|
|
526
516
|
} else {
|
|
527
|
-
|
|
517
|
+
fs.copySync(path.join(templateDir, file), targetPath);
|
|
528
518
|
}
|
|
529
519
|
}
|
|
530
520
|
function read(file, templateName) {
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
GENERATE_SOURCEMAP=false
|
|
2
|
-
|
|
2
|
+
APP_TITLE=''
|
|
@@ -27,7 +27,7 @@ if (isProduction) {
|
|
|
27
27
|
app.use(cors());
|
|
28
28
|
app.use(compression());
|
|
29
29
|
|
|
30
|
-
const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR, '
|
|
30
|
+
const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR, 'dist');
|
|
31
31
|
app.use(express.static(staticDir, { maxAge: '30d', index: false }));
|
|
32
32
|
app.use(router);
|
|
33
33
|
app.use(fallback('index.html', { root: staticDir }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: template-react
|
|
1
|
+
name: template-react-dapp
|
|
2
2
|
title: Blocklet Template React
|
|
3
3
|
description: A Blocklet DAPP blocklet
|
|
4
4
|
keywords:
|
|
@@ -17,7 +17,7 @@ specVersion: 1.1.1
|
|
|
17
17
|
version: 0.1.0
|
|
18
18
|
logo: logo.png
|
|
19
19
|
files:
|
|
20
|
-
-
|
|
20
|
+
- dist
|
|
21
21
|
- logo.png
|
|
22
22
|
- screenshots
|
|
23
23
|
- api/hooks/pre-start.js
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
+
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
+
<title><%- title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
13
|
+
<div id="app"></div>
|
|
14
|
+
<script type="module" src="/src/index.jsx"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev",
|
|
6
|
-
"eject": "
|
|
6
|
+
"eject": "vite eject",
|
|
7
7
|
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
8
8
|
"lint:fix": "npm run lint -- --fix",
|
|
9
9
|
"start": "npm-run-all --parallel start:*",
|
|
10
|
-
"start:client": "
|
|
10
|
+
"start:client": "vite --host",
|
|
11
11
|
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
12
12
|
"clean": "rm -rf .blocklet",
|
|
13
13
|
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
14
|
-
"bundle:client": "
|
|
14
|
+
"bundle:client": "vite build",
|
|
15
15
|
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
16
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
17
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@arcblock/eslint-config": "^0.2.3",
|
|
64
|
-
"@
|
|
64
|
+
"@vitejs/plugin-react": "^2.1.0",
|
|
65
65
|
"eslint": "^8.25.0",
|
|
66
66
|
"husky": "^8.0.1",
|
|
67
67
|
"lint-staged": "^12.5.0",
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
"nodemon": "^2.0.20",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"prettier": "^2.7.1",
|
|
72
|
-
"
|
|
72
|
+
"vite": "^3.1.7",
|
|
73
|
+
"vite-plugin-blocklet": "^0.4.72",
|
|
74
|
+
"vite-plugin-html": "^3.2.0",
|
|
75
|
+
"vite-plugin-svgr": "^2.2.1"
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { createHtmlPlugin } from 'vite-plugin-html';
|
|
4
|
+
import { createBlockletPlugin } from 'vite-plugin-blocklet';
|
|
5
|
+
import svgr from 'vite-plugin-svgr';
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig(async ({ mode }) => {
|
|
9
|
+
const envMap = loadEnv(mode, process.cwd(), '');
|
|
10
|
+
const apiPort = envMap.API_PORT || 3030;
|
|
11
|
+
const apiPrefix = `${process.env.BLOCKLET_DEV_MOUNT_POINT || ''}/api`;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
plugins: [
|
|
15
|
+
react(),
|
|
16
|
+
createHtmlPlugin({
|
|
17
|
+
minify: true,
|
|
18
|
+
inject: {
|
|
19
|
+
data: {
|
|
20
|
+
title: envMap.APP_TITLE,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
createBlockletPlugin(),
|
|
25
|
+
svgr(),
|
|
26
|
+
],
|
|
27
|
+
server: {
|
|
28
|
+
proxy: {
|
|
29
|
+
[apiPrefix]: {
|
|
30
|
+
target: `http://127.0.0.1:${apiPort}`,
|
|
31
|
+
rewrite: (path) => path.replace(apiPrefix, '/api'), // rewrite path when blocklet dev
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
GENERATE_SOURCEMAP=false
|
|
2
|
-
|
|
2
|
+
APP_TITLE=''
|
|
@@ -32,7 +32,7 @@ if (isProduction) {
|
|
|
32
32
|
app.use(cors());
|
|
33
33
|
app.use(compression());
|
|
34
34
|
|
|
35
|
-
const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR, '
|
|
35
|
+
const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR, 'dist');
|
|
36
36
|
app.use(express.static(staticDir, { maxAge: '30d', index: false }));
|
|
37
37
|
app.use(router);
|
|
38
38
|
app.use(fallback('index.html', { root: staticDir }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: template-react
|
|
1
|
+
name: template-react-gunjs
|
|
2
2
|
title: Blocklet Template React
|
|
3
3
|
description: A Blocklet DAPP blocklet
|
|
4
4
|
keywords:
|
|
@@ -17,7 +17,7 @@ specVersion: 1.1.1
|
|
|
17
17
|
version: 0.1.0
|
|
18
18
|
logo: logo.png
|
|
19
19
|
files:
|
|
20
|
-
-
|
|
20
|
+
- dist
|
|
21
21
|
- logo.png
|
|
22
22
|
- screenshots
|
|
23
23
|
- api/hooks/pre-start.js
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
+
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
+
<title><%- title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
13
|
+
<div id="app"></div>
|
|
14
|
+
<script type="module" src="/src/index.jsx"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev",
|
|
6
|
-
"eject": "
|
|
6
|
+
"eject": "vite eject",
|
|
7
7
|
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
8
8
|
"lint:fix": "npm run lint -- --fix",
|
|
9
9
|
"start": "npm-run-all --parallel start:*",
|
|
10
|
-
"start:client": "
|
|
10
|
+
"start:client": "vite --host",
|
|
11
11
|
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
12
12
|
"clean": "rm -rf .blocklet",
|
|
13
13
|
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
14
|
-
"bundle:client": "
|
|
14
|
+
"bundle:client": "vite build",
|
|
15
15
|
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
16
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
17
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
@@ -62,13 +62,16 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@arcblock/eslint-config": "^0.2.3",
|
|
65
|
-
"@
|
|
65
|
+
"@vitejs/plugin-react": "^2.1.0",
|
|
66
66
|
"eslint": "^8.25.0",
|
|
67
67
|
"husky": "^8.0.1",
|
|
68
68
|
"lint-staged": "^12.5.0",
|
|
69
69
|
"nodemon": "^2.0.20",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"prettier": "^2.7.1",
|
|
72
|
-
"
|
|
72
|
+
"vite": "^3.1.7",
|
|
73
|
+
"vite-plugin-blocklet": "^0.4.72",
|
|
74
|
+
"vite-plugin-html": "^3.2.0",
|
|
75
|
+
"vite-plugin-svgr": "^2.2.1"
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -5,7 +5,7 @@ import Gun from 'gun';
|
|
|
5
5
|
import { Link } from 'react-router-dom';
|
|
6
6
|
|
|
7
7
|
const gun = Gun({
|
|
8
|
-
peers: [`${window.location.origin}
|
|
8
|
+
peers: [`${window.location.origin}${window?.blocklet?.prefix || ''}gun`], // Put the relay nodes that you want here
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
export default function Home() {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { createHtmlPlugin } from 'vite-plugin-html';
|
|
4
|
+
import { createBlockletPlugin } from 'vite-plugin-blocklet';
|
|
5
|
+
import svgr from 'vite-plugin-svgr';
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig(async ({ mode }) => {
|
|
9
|
+
const envMap = loadEnv(mode, process.cwd(), '');
|
|
10
|
+
const apiPort = envMap.API_PORT || 3030;
|
|
11
|
+
const apiPrefix = `${process.env.BLOCKLET_DEV_MOUNT_POINT || ''}/api`;
|
|
12
|
+
const gunPrefix = '/gun'; // ws suffix only supports first level paths
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
plugins: [
|
|
16
|
+
react(),
|
|
17
|
+
createHtmlPlugin({
|
|
18
|
+
minify: true,
|
|
19
|
+
inject: {
|
|
20
|
+
data: {
|
|
21
|
+
title: envMap.APP_TITLE,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
createBlockletPlugin(),
|
|
26
|
+
svgr(),
|
|
27
|
+
],
|
|
28
|
+
server: {
|
|
29
|
+
proxy: {
|
|
30
|
+
[apiPrefix]: {
|
|
31
|
+
target: `http://127.0.0.1:${apiPort}`,
|
|
32
|
+
rewrite: (path) => path.replace(apiPrefix, '/api'), // rewrite path when blocklet dev
|
|
33
|
+
},
|
|
34
|
+
[gunPrefix]: {
|
|
35
|
+
target: `ws://127.0.0.1:${apiPort}`,
|
|
36
|
+
ws: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
GENERATE_SOURCEMAP=false
|
|
2
|
-
|
|
2
|
+
APP_TITLE=''
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
+
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
+
<title><%- title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
13
|
+
<div id="app"></div>
|
|
14
|
+
<script type="module" src="/src/index.jsx"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev",
|
|
6
|
-
"eject": "
|
|
6
|
+
"eject": "vite eject",
|
|
7
|
+
"serve": "vite preview",
|
|
7
8
|
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
8
9
|
"lint:fix": "npm run lint -- --fix",
|
|
9
|
-
"start": "
|
|
10
|
+
"start": "vite --host",
|
|
10
11
|
"clean": "rm -rf .blocklet",
|
|
11
|
-
"bundle": "npm run clean &&
|
|
12
|
+
"bundle": "npm run clean && vite build && blocklet bundle --zip --create-release",
|
|
12
13
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
13
14
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
14
15
|
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
|
|
@@ -43,11 +44,14 @@
|
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@arcblock/eslint-config": "^0.2.3",
|
|
46
|
-
"@
|
|
47
|
+
"@vitejs/plugin-react": "^2.1.0",
|
|
47
48
|
"eslint": "^8.25.0",
|
|
48
49
|
"husky": "^8.0.1",
|
|
49
50
|
"lint-staged": "^12.5.0",
|
|
50
51
|
"prettier": "^2.7.1",
|
|
51
|
-
"
|
|
52
|
+
"vite": "^3.1.7",
|
|
53
|
+
"vite-plugin-blocklet": "^0.4.72",
|
|
54
|
+
"vite-plugin-html": "^3.2.0",
|
|
55
|
+
"vite-plugin-svgr": "^2.2.1"
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { createHtmlPlugin } from 'vite-plugin-html';
|
|
4
|
+
import { createBlockletPlugin } from 'vite-plugin-blocklet';
|
|
5
|
+
import svgr from 'vite-plugin-svgr';
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig(async ({ mode }) => {
|
|
9
|
+
const envMap = loadEnv(mode, process.cwd(), '');
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
plugins: [
|
|
13
|
+
react(),
|
|
14
|
+
createHtmlPlugin({
|
|
15
|
+
minify: true,
|
|
16
|
+
inject: {
|
|
17
|
+
data: {
|
|
18
|
+
title: envMap.APP_TITLE,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
createBlockletPlugin(),
|
|
23
|
+
svgr(),
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
});
|
|
@@ -7,6 +7,7 @@ import { createBlockletPlugin } from 'vite-plugin-blocklet';
|
|
|
7
7
|
export default defineConfig(async ({ mode }) => {
|
|
8
8
|
const envMap = loadEnv(mode, process.cwd(), '');
|
|
9
9
|
const apiPort = envMap.API_PORT || 3030;
|
|
10
|
+
const apiPrefix = `${process.env.BLOCKLET_DEV_MOUNT_POINT || ''}/api`;
|
|
10
11
|
|
|
11
12
|
return {
|
|
12
13
|
plugins: [
|
|
@@ -23,7 +24,10 @@ export default defineConfig(async ({ mode }) => {
|
|
|
23
24
|
],
|
|
24
25
|
server: {
|
|
25
26
|
proxy: {
|
|
26
|
-
|
|
27
|
+
[apiPrefix]: {
|
|
28
|
+
target: `http://127.0.0.1:${apiPort}`,
|
|
29
|
+
rewrite: (path) => path.replace(apiPrefix, '/api'), // rewrite path when blocklet dev
|
|
30
|
+
},
|
|
27
31
|
},
|
|
28
32
|
},
|
|
29
33
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
require('dotenv-flow').config();
|
|
2
2
|
|
|
3
|
+
const mountPoint = process.env.BLOCKLET_DEV_MOUNT_POINT || '';
|
|
3
4
|
const port = process.env.BLOCKLET_PORT || process.env.PORT || 3000;
|
|
4
5
|
const apiPort = process.env.API_PORT || 3030;
|
|
5
|
-
|
|
6
|
+
const apiPrefix = `${mountPoint}/api`;
|
|
6
7
|
const whenDev = process.env.NODE_ENV === 'development';
|
|
7
8
|
|
|
8
|
-
const mountPoint = process.env.BLOCKLET_DEV_MOUNT_POINT || '';
|
|
9
|
-
|
|
10
9
|
module.exports = {
|
|
11
10
|
publicPath: whenDev ? '' : process.env.PUBLIC_PATH || '/',
|
|
12
11
|
devServer: {
|
|
@@ -17,8 +16,9 @@ module.exports = {
|
|
|
17
16
|
webSocketURL: `wss://0.0.0.0${mountPoint}/ws`,
|
|
18
17
|
},
|
|
19
18
|
proxy: {
|
|
20
|
-
|
|
19
|
+
[apiPrefix]: {
|
|
21
20
|
target: `http://127.0.0.1:${apiPort}`,
|
|
21
|
+
rewrite: (path) => path.replace(apiPrefix, '/api'), // rewrite path when blocklet dev
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
},
|
package/common/_gitignore
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
.pnp
|
|
5
|
-
.pnp.js
|
|
6
|
-
.DS_Store
|
|
7
|
-
node_modules
|
|
8
|
-
|
|
9
|
-
# testing
|
|
10
|
-
coverage
|
|
11
|
-
|
|
12
|
-
# production
|
|
13
|
-
build
|
|
14
|
-
dist
|
|
15
|
-
dist-ssr
|
|
16
|
-
.blocklet
|
|
17
|
-
|
|
18
|
-
# local env files
|
|
19
|
-
*.local
|
|
20
|
-
|
|
21
|
-
# Log files
|
|
22
|
-
logs
|
|
23
|
-
*.log
|
|
24
|
-
npm-debug.log*
|
|
25
|
-
yarn-debug.log*
|
|
26
|
-
yarn-error.log*
|
|
27
|
-
pnpm-debug.log*
|
|
28
|
-
lerna-debug.log*
|
package/common/_npmrc
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require('dotenv-flow').config();
|
|
2
|
-
|
|
3
|
-
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
|
|
4
|
-
|
|
5
|
-
const port = process.env.BLOCKLET_PORT || process.env.PORT || 3000;
|
|
6
|
-
const apiPort = process.env.API_PORT || 3030;
|
|
7
|
-
const whenDev = process.env.NODE_ENV === 'development';
|
|
8
|
-
const mountPoint = process.env.BLOCKLET_DEV_MOUNT_POINT || '';
|
|
9
|
-
|
|
10
|
-
const plugins = [new NodePolyfillPlugin({ excludeAliases: ['console'] })];
|
|
11
|
-
|
|
12
|
-
const webpackConfig = whenDev
|
|
13
|
-
? {
|
|
14
|
-
configure: {
|
|
15
|
-
output: {
|
|
16
|
-
publicPath: '', // When the dev mode as component, this line required
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
plugins,
|
|
20
|
-
}
|
|
21
|
-
: { plugins };
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
webpack: {
|
|
25
|
-
...webpackConfig,
|
|
26
|
-
},
|
|
27
|
-
devServer: {
|
|
28
|
-
port,
|
|
29
|
-
client: {
|
|
30
|
-
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
31
|
-
webSocketURL: `wss://0.0.0.0${mountPoint}/ws`,
|
|
32
|
-
},
|
|
33
|
-
proxy: {
|
|
34
|
-
'/api': {
|
|
35
|
-
target: `http://127.0.0.1:${apiPort}`,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
-
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
-
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
-
<script src="__meta__.js"></script>
|
|
10
|
-
<!--
|
|
11
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
12
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
13
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
14
|
-
|
|
15
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
16
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
17
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
18
|
-
-->
|
|
19
|
-
<title>%REACT_APP_TITLE%</title>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
23
|
-
<div id="root"></div>
|
|
24
|
-
<!--
|
|
25
|
-
This HTML file is a template.
|
|
26
|
-
If you open it directly in the browser, you will see an empty page.
|
|
27
|
-
|
|
28
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
29
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
30
|
-
|
|
31
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
32
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
33
|
-
-->
|
|
34
|
-
</body>
|
|
35
|
-
</html>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require('dotenv-flow').config();
|
|
2
|
-
|
|
3
|
-
const port = process.env.BLOCKLET_PORT || process.env.PORT || 3000;
|
|
4
|
-
const apiPort = process.env.API_PORT || 3030;
|
|
5
|
-
|
|
6
|
-
const whenDev = process.env.NODE_ENV === 'development';
|
|
7
|
-
|
|
8
|
-
const mountPoint = process.env.BLOCKLET_DEV_MOUNT_POINT || '';
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
devServer: {
|
|
12
|
-
port,
|
|
13
|
-
client: {
|
|
14
|
-
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
15
|
-
webSocketURL: `wss://0.0.0.0${mountPoint}/ws`,
|
|
16
|
-
},
|
|
17
|
-
proxy: [
|
|
18
|
-
{
|
|
19
|
-
context: ['/api'],
|
|
20
|
-
target: `http://127.0.0.1:${apiPort}`,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
context: ['/gun'],
|
|
24
|
-
target: `ws://127.0.0.1:${apiPort}`,
|
|
25
|
-
ws: true,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
webpack: {
|
|
30
|
-
configure: {
|
|
31
|
-
module: {
|
|
32
|
-
noParse: /gun\.js$/,
|
|
33
|
-
},
|
|
34
|
-
output: whenDev
|
|
35
|
-
? {
|
|
36
|
-
publicPath: '', // When the dev mode as component, this line required
|
|
37
|
-
}
|
|
38
|
-
: {},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
-
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
-
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
-
<script src="__meta__.js"></script>
|
|
10
|
-
<!--
|
|
11
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
12
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
13
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
14
|
-
|
|
15
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
16
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
17
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
18
|
-
-->
|
|
19
|
-
<title>%REACT_APP_TITLE%</title>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
23
|
-
<div id="root"></div>
|
|
24
|
-
<!--
|
|
25
|
-
This HTML file is a template.
|
|
26
|
-
If you open it directly in the browser, you will see an empty page.
|
|
27
|
-
|
|
28
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
29
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
30
|
-
|
|
31
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
32
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
33
|
-
-->
|
|
34
|
-
</body>
|
|
35
|
-
</html>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const port = process.env.BLOCKLET_PORT || process.env.PORT || 3000;
|
|
2
|
-
|
|
3
|
-
const whenDev = process.env.NODE_ENV === 'development';
|
|
4
|
-
|
|
5
|
-
const mountPoint = process.env.BLOCKLET_DEV_MOUNT_POINT || '';
|
|
6
|
-
|
|
7
|
-
const webpackConfig = whenDev
|
|
8
|
-
? {
|
|
9
|
-
configure: {
|
|
10
|
-
output: {
|
|
11
|
-
publicPath: '', // When the dev mode as component, this line required
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
}
|
|
15
|
-
: {};
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
webpack: {
|
|
19
|
-
...webpackConfig,
|
|
20
|
-
},
|
|
21
|
-
devServer: {
|
|
22
|
-
port,
|
|
23
|
-
client: {
|
|
24
|
-
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
25
|
-
webSocketURL: `wss://0.0.0.0${mountPoint}/ws`,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
-
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
-
<meta name="description" content="Web site created using create-blocklet" />
|
|
9
|
-
<script src="__meta__.js"></script>
|
|
10
|
-
<!--
|
|
11
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
12
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
13
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
14
|
-
|
|
15
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
16
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
17
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
18
|
-
-->
|
|
19
|
-
<title>%REACT_APP_TITLE%</title>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
23
|
-
<div id="root"></div>
|
|
24
|
-
<!--
|
|
25
|
-
This HTML file is a template.
|
|
26
|
-
If you open it directly in the browser, you will see an empty page.
|
|
27
|
-
|
|
28
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
29
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
30
|
-
|
|
31
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
32
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
33
|
-
-->
|
|
34
|
-
</body>
|
|
35
|
-
</html>
|