About
bespoke-cli provides several commands for developers to increase speed of developing games based on
@ancademy/bespoke-xxx framework. It packs some tasks of webpack and file operation , and you can refer to source code in
/src to custom your own task.
Install
npm i -g @ancademy/bespoke-cli
Commands
Options:
-v --version output the version number
-h, --help display help for command
Commands:
init init base project structure
add add new sub game
dev dev a sub game
build build a sub game
extra extra util tasks
help [command] display help for command
Start
Init project
mkdir hello-bespoke
cd hello-bespoke
bespoke-cli init
# Input project name : hello-bespoke
Add first game
bespoke-cli add
# Input game namespace : openAuction
As for the namespace
, the first letter will be converted to uppercase,and then used as the game folder name. You can
freely modify it later in config.ts
, and it will become the routing prefix of the game. When you modify it in '
config.ts', it can be shaped like '/auction/openAuction', as a multi-layer prefix.
Dev
Frontend
bespoke-cli -> choose game (OpenAuction) -> client -> HMR
The frontend code would be built by webpack-dev-server and served at port 8080 ,and HMR will be enabled when Y is
selected.
Custom webpack config in config.ts
:
export function updateWebpack(config) {
//update
return config;
}
Backend
Visit
- Refer to console log, browse
http://ip:port/OpenAuction
.
- Register-free Experience(Teacher) -> (Password 111111) -> Create Room -> Configure room parameters ->
Submit -> Automatically redirect to the room console page.
- Add Player (Player A) -> Click to open a new tab to play with the identity of this player.
Build
bespoke-cli build -> choose game (OpenAuction) -> dist/publish
Frontend code would be packaged into namespace/dist
,while backend into namespace/build
. Compared with dist
, publish
will upload the frontend bundle to Qiniu based on the keys in .env
.
Deploy
- upload
package.json + dist + build
to remote server
npm i
node ./build/serve.js