Skip to content

Commit 76469e6

Browse files
xcv58conwnet
andauthored
Use webpack to replace shell script and simplify the logic (conwnet#412)
Co-authored-by: netcon <netcon@live.com>
1 parent a5748f8 commit 76469e6

16 files changed

Lines changed: 1956 additions & 338 deletions

‎README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ git clone git@github.com:conwnet/github1s.git
6262
cd github1s
6363
yarn
6464
yarn watch
65-
yarn serve # in another shell
66-
# Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
65+
# The cli will automatically open http://localhost:5000 once the build is completed.
66+
# You can visit http://localhost:5000/conwnet/github1s if it doesn't.
6767
```
6868

6969
#### Local development with full VS Code build
@@ -84,8 +84,8 @@ After the inital successful build, you could use the watch mode:
8484
cd github1s
8585
yarn
8686
yarn watch-with-vscode
87-
yarn serve # in another shell
88-
# Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
87+
# The cli will automatically open http://localhost:5000 once the build is completed.
88+
# You can visit http://localhost:5000/conwnet/github1s if it doesn't.
8989
```
9090

9191
### ... or ... VS Code + Docker Development
@@ -104,8 +104,8 @@ You can use the VS Code plugin [Remote-Containers](https://marketplace.visualstu
104104
```bash
105105
yarn
106106
yarn watch
107-
yarn serve # in another shell
108-
# Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
107+
# The cli will automatically open http://localhost:5000 once the build is completed.
108+
# You can visit http://localhost:5000/conwnet/github1s if it doesn't.
109109
```
110110

111111
### Format all codes

‎docs/guide.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ $ yarn
3535
$ yarn watch # or yarn build, it may take minutes, wait please
3636
```
3737

38-
Then, there will be a new directory named `dist` generated in the project root. You can run `yarn serve` in another shell, and it will create a static file server for the `dist` directory.
38+
Then, there will be a new directory named `dist` generated in the project root. The `yarn watch:dev-server` (part of `yarn watch` command) will automatically open http://localhost:5000 in the browser.
3939

40-
Now you can visit http://localhost:5000 in the browser. If you get a 404 error for some static files, please wait a minute for the building to complete.
40+
If you get a 404 error for some static files, please wait a minute for the building to complete.
4141

4242
## Watch Mode
4343

‎package.json‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
"@typescript-eslint/eslint-plugin": "^4.15.0",
1212
"@typescript-eslint/parser": "^4.15.0",
1313
"chokidar": "^3.5.1",
14+
"copy-webpack-plugin": "^11.0.0",
1415
"eslint": "^7.19.0",
1516
"eslint-config-prettier": "^7.2.0",
1617
"eslint-plugin-jsdoc": "^31.6.1",
1718
"eslint-plugin-prettier": "^3.3.1",
1819
"fs-extra": "^9.1.0",
20+
"generate-file-webpack-plugin": "^1.0.1",
1921
"http-proxy": "^1.18.1",
2022
"husky": "^5.0.9",
2123
"lint-staged": "^10.5.4",
@@ -24,10 +26,12 @@
2426
"serve-handler": "^6.1.3",
2527
"start-server-and-test": "^1.12.0",
2628
"typescript": "^4.1.3",
29+
"webpack": "^5.72.1",
30+
"webpack-cli": "^4.9.2",
31+
"webpack-dev-server": "^4.9.0",
2732
"yalc": "^1.0.0-pre.50"
2833
},
2934
"scripts": {
30-
"dev": "run-p watch serve",
3135
"preinstall": "./scripts/preinstall.sh",
3236
"postinstall": "husky install && ./scripts/postinstall.sh",
3337
"clean-build": "./scripts/clean-build.sh",
@@ -37,17 +41,16 @@
3741
"build:vscode": "cd vscode-web && yarn build",
3842
"vercel-build": "yarn build && yarn hash && rm -rf public && mv dist public",
3943
"hash": "./scripts/hash.sh",
40-
"package": "./scripts/package.sh",
44+
"package": "yarn webpack",
4145
"watch": "rm -rf dist && run-p watch:*",
4246
"watch-with-vscode": "DEV_VSCODE=true run-p watch watch-vscode",
4347
"watch-vscode": "cd vscode-web && yarn watch",
44-
"watch:setup": "./scripts/watch-setup.sh",
45-
"watch:dist": "cd scripts/watch && node watch-dist.js",
48+
"watch:dev-server": "node server.js",
49+
"webpack": "webpack --config webpack.config.js",
4650
"watch:github1s-extension": "cd extensions/github1s && yarn dev",
47-
"serve": "node ./scripts/serve-dist.js",
4851
"format": "prettier --write .",
4952
"eslint": "eslint --ext .ts --ext .js .",
50-
"test:ci": "start-test serve 5000 test",
53+
"test:ci": "start-test watch:dev-server 5000 test",
5154
"test": "cd tests && yarn && yarn jest"
5255
},
5356
"lint-staged": {

‎scripts/build.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ APP_ROOT=$(pwd)
77
# execute all necessary tasks
88
function main() {
99
rm -rf "${APP_ROOT}/dist"
10-
cd "${APP_ROOT}/scripts"
11-
./build/build-github1s-extensions.sh
12-
./package.sh
10+
cd "${APP_ROOT}"
11+
./scripts/build/build-github1s-extensions.sh
12+
yarn webpack
1313

1414
echo "all build done!"
1515
}

‎scripts/package.sh‎

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

‎scripts/package/copy-extensions.js‎

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

‎scripts/package/copy-extensions.sh‎

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

‎scripts/package/copy-node_modules.sh‎

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

‎scripts/package/copy-resources.sh‎

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

‎scripts/package/generate-config.js‎

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

0 commit comments

Comments
 (0)