File size: 3,547 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# Command Line Commands
## Initialization
```Shell
npm run setup
```
Initializes a new project with this boilerplate. Deletes the `react-boilerplate`
git history, installs the dependencies and initializes a new repository.
> Note: This command is self-destructive, once you've run it the init script is
> gone forever. This is for your own safety, so you can't delete your project's
> history irreversibly by accident.
## Development
```Shell
npm run start
```
Starts the development server running on `http://localhost:3000`
## Cleaning
```Shell
npm run clean
```
Deletes the example app, replacing it with the smallest amount of boilerplate
code necessary to start writing your app!
> Note: This command is self-destructive, once you've run it you cannot run it
> again. This is for your own safety, so you can't delete portions of your project
> irreversibly by accident.
## Generators
```Shell
npm run generate
```
Allows you to auto-generate boilerplate code for common parts of your
application, specifically `component`s, and `container`s. You can
also run `npm run generate <part>` to skip the first selection. (e.g. `npm run generate container`)
## Server
### Development
```Shell
npm start
```
Starts the development server and makes your application accessible at
`localhost:3000`. Changes in the application code will be hot-reloaded.
### Production
```Shell
npm run start:production
```
- Runs tests (see `npm test`)
- Builds your app (see `npm run build`)
- Starts the production server (see `npm run start:prod`)
The app is built for optimal performance: assets are
minified and served gzipped.
### Host and Port
To change the host and/or port the app is accessible at, pass the `--host` and/or `--port` option to the command
with `--`. E.g. to make the app visible at `my-local-hostname:5000`, run the following:
`npm start -- --host my-local-hostname --port 5000`
## Building
```Shell
npm run build
```
Preps your app for deployment (does not run tests). Optimizes and minifies all files, piping them to the `build` folder.
Upload the contents of `build` to your web server to
see your work live!
## Testing
See the [testing documentation](../testing/README.md) for detailed information
about our testing setup!
## Unit testing
```Shell
npm test
```
Tests your application with the unit tests specified in the `**/tests/*.js` files
throughout the application.
All the `test` commands allow an optional `-- [string]` argument to filter
the tests run by Jest. Useful if you need to run a specific test only.
```Shell
# Run only the Button component tests
npm test -- Button
```
### Watching
```Shell
npm run test:watch
```
Watches changes to your application and re-runs tests whenever a file changes.
### Remote testing
```Shell
npm run start:tunnel
```
Starts the development server and tunnels it with `ngrok`, making the website
available worldwide. Useful for testing on different devices in different locations!
### Dependency size test
```Shell
npm run analyze
```
This command will generate a `stats.json` file from your production build, which
you can upload to the [webpack analyzer](https://webpack.github.io/analyse/) or [Webpack Visualizer](https://chrisbateman.github.io/webpack-visualizer/). This
analyzer will visualize your dependencies and chunks with detailed statistics
about the bundle size.
## Linting
```Shell
npm run lint
```
Lints your JavaScript and your CSS.
```Shell
npm run lint:eslint:fix -- .
```
Lints your code and tries to fix any errors it finds.
|