UNPKG

5.24 kBMarkdownView Raw
1### Build App
2
3**Build App** is a full-stack JS App build system. Inspired by Facebook's create-react-app and other client build systems it is going one step futher providing similar facilities for full-stack JS development.
4
5The aim of the project is to simplify development of modern full-stack JS applications, providing most of basic dev operations out of the box (build, run dev mode, lint, etc).
6
7Besides that it provides number of build in starter templates which will help you get started ASAP. There are number of technology choises such as React/Vue/Angular for client, Mongo/Postgres for storage.
8
9*Build App* works on macOS, Windows, and Linux.
10Project is in early stage of development.
11If something doesn’t work please file an issue.
12
13## Getting started
14
15```sh
16# install build-app globally
17npm install -g build-app
18
19# see list of available commands
20app-scripts --help
21
22# init empty project with default templates
23app-scripts init my-app --default
24
25# change directory to new project folder
26cd my-app
27
28# install project dependencies
29app-scripts install
30
31# build project for production (and before running in dev mode)
32app-scripts build
33
34# serve project in dev mode
35app-scripts serve --server (--client)
36
37```
38
39## Project structure
40
41*Build App* assumes some predifined project structure.
42
43Project consists of server and client parts.
44
45By default server part is located in {root}/server folder and client in {root}/client.
46
47Those values can be overriden in build-app.config.
48
49### Client:
50
51Client is SPA written in one modern JS front-end frameworks. Officially supported are React, Vue and Angular2. They are using existing client side build systems (create-react-app, vbuild and angular-cli respectively).
52
53Build system expects to be able to create client build by running 'npm run build' command in client folder. Output is expected in {client}/build folder and index.html starts client SPA application.
54
55More details how to setup client-side build you can find in docs for particualr build system:
56
57React: [create-react-app](https://github.com/facebookincubator/create-react-app)
58
59Vue: [vbuild](https://github.com/egoist/vbuild)
60
61Angular: [angular-cli](https://github.com/angular/angular-cli)
62
63### Server:
64
65Both JS/TS js flavors are supported. For JS you can use latest language features like ES6, async/await and others. Code is compiled to ES5 during the build.
66
67Server entry file should be located at ./src/index (.ts or .js).
68
69There are some special folders
70
71**data**: folder with data assets like data json files, email templates, etc.
72
73**local**: folder where server writes data to, here you can have logs output, local overrided values for config file, file uploads, etc.
74
75## app-script commands
76
77After build-app is installed globally app-scripts command is available globally. It has different commands (scripts).
78
79### Init
80*init* command seeds empty project. There are separate templates for server and client parts.
81
82To see all available templates run:
83
84```sh
85app-scripts init --list
86```
87
88To seed project with particular templates use --project --server --client options:
89
90```sh
91app-scripts init my-app --project simple --server ts --client react
92```
93To init basic IDE settings use option --ide (currently supported ws/code)
94
95```
96app-scripts init my-app --default --ide code
97```
98
99### Install
100
101*install* command installs dependencies for both client and server project parts. It can use one of following package managers under the hood: npm, yarn, pnpm. If pnpm is installed globally it is used, then yarn used if available, then npm.
102
103The same can be done manually with
104
105```sh
106cd {server_dir}
107npm install
108
109cd ../{client_dir}
110npm install
111```
112
113### Build
114
115*build* command creates production ready build in build folder (./build by default).
116
117To start server run index.js file. You may need to install dependencies first.
118
119Build command builds server and client separately and then combines them together into build package.
120
121### Deploy
122
123Deploys application in various modes (by using target parameter):
124
125*local* deployments:
126
127```bash
128napp deploy
129```
130
131Build package copied to deployment folder (./deploy by default) and starts the application with one of supported process managers (forever or pm2). Following deployments will stop application first and clear all deploy folder content except local folder.
132
133*heroku* deployments:
134
135Initial setup
136
137```bash
138cd deploy/
139git init
140heroku git:remote -a {APP_ID} -r {REMOTE_NAME}
141git fetch {REMOTE_NAME}
142git checkout {REMOTE_NAME}/master -b {REMOTE_NAME}
143```
144
145Note that that you can have multiple remotes corresponding to different environments (dev/staging)
146
147After that you can do:
148
149```bash
150napp deploy --target heroku --remote dev
151```
152
153## Npm Scripts
154
155Some operations are expected to be configured as particular npm scripts:
156
157Build client - 'build' script (in client folder)
158
159Serve client - 'start' script
160
161Serve server - 'start' script (in server folder)
162
163Also if pre-build/post-build scripts are defined in server/client package.json files corresponding scripts will be executed before/after server/client builds.
\No newline at end of file