Skip to content

Commit 12ac93f

Browse files
committed
chore: build
1 parent c792ee6 commit 12ac93f

File tree

6 files changed

+90
-18
lines changed

6 files changed

+90
-18
lines changed

build/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>@saber2pr/react</title>
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
<script src=//cdn.jsdelivr.net/gh/saber2pr/react@gh-pages/bundle.1624718024426.js></script>
9+
</body>
10+
</html>

index.html

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@
1919
"scripts": {
2020
"start": "tsc --watch",
2121
"dev": "rollup -c --watch",
22-
"test": "node ./lib/__test__/TestSSR"
22+
"test": "node ./lib/__test__/TestSSR",
23+
"build": "tsc && cross-env NODE_ENV=production rollup -c"
2324
},
2425
"keywords": [
2526
"react-like",
2627
"react-hooks",
2728
"typescript"
2829
],
2930
"devDependencies": {
31+
"@rollup/plugin-html": "^0.2.3",
32+
"cross-env": "^7.0.3",
3033
"rollup": "^1.27.8",
3134
"rollup-plugin-commonjs": "^9.2.0",
3235
"rollup-plugin-node-resolve": "^5.2.0",
3336
"rollup-plugin-uglify": "^6.0.3",
3437
"typescript": "^3.4.3"
3538
}
36-
}
39+
}

rollup.config.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
import resolve from "rollup-plugin-node-resolve"
22
import commonjs from "rollup-plugin-commonjs"
33
import { uglify } from "rollup-plugin-uglify"
4+
import html from '@rollup/plugin-html'
5+
6+
const cdn = '//cdn.jsdelivr.net/gh'
7+
const username = 'saber2pr'
8+
const repo = 'react'
9+
const pages_branch = 'gh-pages'
10+
11+
const publicPath = process.env.NODE_ENV === 'production'
12+
? `${cdn}/${username}/${repo}@${pages_branch}/`
13+
: './'
14+
15+
const fileName = `bundle.${Date.now()}.js`
416

517
export default {
618
input: "./lib/__test__/Test.js",
719
output: {
8-
file: "./build/bundle.js",
20+
file: `./build/${fileName}`,
921
format: "iife",
1022
name: "react",
1123
exports: "named"
1224
},
1325
watch: {
1426
include: "lib/**"
1527
},
16-
plugins: [commonjs(), resolve(), uglify()]
28+
plugins: [commonjs(), resolve(), uglify(), html({
29+
template: () => `<!DOCTYPE html>
30+
<html>
31+
<head>
32+
<title>@saber2pr/react</title>
33+
</head>
34+
<body>
35+
<div id="root"></div>
36+
<script src=${`${publicPath}${fileName}`}></script>
37+
</body>
38+
</html>`
39+
})]
1740
}

yarn.lock

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
esutils "^2.0.2"
1919
js-tokens "^4.0.0"
2020

21+
"@rollup/plugin-html@^0.2.3":
22+
version "0.2.3"
23+
resolved "https://registry.npm.taobao.org/@rollup/plugin-html/download/@rollup/plugin-html-0.2.3.tgz#bed48fc18dbde345c0ef09b0b53a165d7bd3b7cd"
24+
integrity sha1-vtSPwY2940XA7wmwtToWXXvTt80=
25+
2126
"@types/estree@*":
2227
version "0.0.40"
2328
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.40.tgz#0e6cb9b9bbd098031fa19e4b4e8131bc70e5de13"
@@ -78,6 +83,22 @@ commander@~2.20.3:
7883
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
7984
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
8085

86+
cross-env@^7.0.3:
87+
version "7.0.3"
88+
resolved "https://registry.nlark.com/cross-env/download/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
89+
integrity sha1-hlJkspZ33AFbqEGJGJZd0jL8VM8=
90+
dependencies:
91+
cross-spawn "^7.0.1"
92+
93+
cross-spawn@^7.0.1:
94+
version "7.0.3"
95+
resolved "https://registry.nlark.com/cross-spawn/download/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
96+
integrity sha1-9zqFudXUHQRVUcF34ogtSshXKKY=
97+
dependencies:
98+
path-key "^3.1.0"
99+
shebang-command "^2.0.0"
100+
which "^2.0.1"
101+
81102
escape-string-regexp@^1.0.5:
82103
version "1.0.5"
83104
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@@ -103,6 +124,11 @@ is-module@^1.0.0:
103124
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
104125
integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=
105126

127+
isexe@^2.0.0:
128+
version "2.0.0"
129+
resolved "https://registry.npm.taobao.org/isexe/download/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
130+
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
131+
106132
jest-worker@^24.0.0:
107133
version "24.9.0"
108134
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5"
@@ -128,6 +154,11 @@ merge-stream@^2.0.0:
128154
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
129155
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
130156

157+
path-key@^3.1.0:
158+
version "3.1.1"
159+
resolved "https://registry.nlark.com/path-key/download/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
160+
integrity sha1-WB9q3mWMu6ZaDTOA3ndTKVBU83U=
161+
131162
path-parse@^1.0.6:
132163
version "1.0.6"
133164
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
@@ -192,6 +223,18 @@ serialize-javascript@^1.9.0:
192223
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.1.tgz#cfc200aef77b600c47da9bb8149c943e798c2fdb"
193224
integrity sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==
194225

226+
shebang-command@^2.0.0:
227+
version "2.0.0"
228+
resolved "https://registry.nlark.com/shebang-command/download/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
229+
integrity sha1-zNCvT4g1+9wmW4JGGq8MNmY/NOo=
230+
dependencies:
231+
shebang-regex "^3.0.0"
232+
233+
shebang-regex@^3.0.0:
234+
version "3.0.0"
235+
resolved "https://registry.npm.taobao.org/shebang-regex/download/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
236+
integrity sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=
237+
195238
source-map@~0.6.1:
196239
version "0.6.1"
197240
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
@@ -228,3 +271,10 @@ uglify-js@^3.4.9:
228271
dependencies:
229272
commander "~2.20.3"
230273
source-map "~0.6.1"
274+
275+
which@^2.0.1:
276+
version "2.0.2"
277+
resolved "https://registry.nlark.com/which/download/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
278+
integrity sha1-fGqN0KY2oDJ+ELWckobu6T8/UbE=
279+
dependencies:
280+
isexe "^2.0.0"

0 commit comments

Comments
 (0)