UNPKG

2.1 kBMarkdownView Raw
1# Create JS App
2
3Create full stack javascript apps with no build configuration and one dependency.
4
5## Installation
6
7```sh
8npm install -g create-js-app
9
10create-js-app my-app
11cd my-app/
12npm start
13```
14
15Then open [http://localhost:3000](http://localhost:3000) to see your app.
16
17## Development
18
19To start development run following command in project root directory.
20
21```sh
22npm start
23```
24
25## Production
26
27To create a minified build run following command in project root directory.
28
29```sh
30npm run build
31```
32
33## Configuration
34
35```js
36// .app.js file in project directory
37
38module.exports = {
39 // default is create-js-app-scripts/scripts/config/eslint/default.js
40 eslint: 'create-js-app-scripts/scripts/config/eslint/airbnb.js',
41
42 // tasks you want to run during development
43 // it will terminate them when you terminate development script
44 tasks: [
45 (eventEmitter) => {
46 // do something, maybe watch files using chokidar, anything
47 eventEmitter.emit('task-log', 'some info');
48 eventEmitter.emit('task-log-error', 'some info');
49 eventEmitter.emit('task-log-info', 'some info');
50 eventEmitter.emit('task-log-success', 'some info');
51 eventEmitter.emit('task-log-warning', 'some info');
52
53 return {
54 /**
55 * This is used to terminate task when command receives SIGTERM
56 * @returns {Promise}
57 */
58 terminate() {
59 return Promise.resolve();
60 }
61 }
62 }
63 ]
64};
65```
66
67## Directory structure
68**There is not an init command at the time so you need to create this manually**
69
70```
71src
72 /client
73 /index.js
74 /server
75 /index.js
76```
77
78```js
79// example of server side javascript file
80// you can use any node.js http framework
81// but you have to export listener
82// so create-js-app can manage it
83//src/server/index.js
84
85import Koa from 'koa';
86
87const app = new Koa();
88
89// SERVER_PORT is provided by webpack build
90const listener = app.listen(SERVER_PORT);
91
92export default listener;
93
94```