3.2.3 • Published 2 years ago

relient-cli v3.2.3

Weekly downloads
174
License
MIT
Repository
github
Last release
2 years ago

Relient-CLI

Relient CLI is a cli wrapper of react-starter-kit. It also provides API mock.

Install

$ npm install relient-cli --save-dev

Basic usage

Make sure you have below project structure:

  • mocker/ API mock config
  • public/ static public files, for example: robots.txt, favicon.ico
  • src/
    • client/ client side code
      • index.js client side entry file
    • server/ server side code
      • index.js server side entry file
    • shared/ code shared with client and server

And add below scripts into package.json:

"scripts": {
	"clean": "relient clean",
	"copy": "relient copy",
	"bundle": "relient bundle",
	"build": "relient build",
	"build-stats": "relient build --analyse",
	"serve": "relient runServer",
	"start": "relient start",
	"mocker": "relient mocker"
}

Then npm run start will give you a working isomorphic web application in dev environment.

Scripts

relient clean

Clear build folder.

relient copy

Copy all files from public folder and yarn.lock to build. If you run with --watch, files will be copy when changed automatically.

relient bundle

Create application bundles (both client and server side) with webpack compilation.

relient build

Run clean, copy, bundle in sequence. When you want to release your app to prod, please run this script.

relient build --analyse

This will show a build stats with BundleAnalyzerPlugin

relient start

Start the application in dev enironment.

relient mocker

Run mock server.

Config

Add relient.config.js in the root of your project to config relient. The default config will be:

{
  mockerPort: 9001,
  clientConfigs: [],
  babelPlugins: [],
  proxy: {
    from: ['/api'],
    target: 'http://localhost:9001',
    changeOrigin: true,
  },
  baseUrl: '/admin', // This will be used to webpack public path and browserSync startPath
}

You can add your custom config in relient.config.js to overwrite the default value or add a new config value.

Mock

The mock is built based on express. For example, we can create a mocker for account:

mocker/account.js

export default (router) => {
  router.post('/account', ({ body }, response) => {
    response.status(200).send(body);
  });

  router.get('/account/all', (request, response) => {
    response.status(200).send([{ id: 1, name: 'A' }, { id: 2, name: 'B' }]);
  });
}
3.2.3

2 years ago

3.2.2

2 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.7.9

4 years ago

2.7.8

4 years ago

2.7.7

4 years ago

2.7.6

4 years ago

2.7.5

4 years ago

2.6.5

4 years ago

2.6.4

4 years ago

2.6.3

4 years ago

2.6.2

4 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.0

5 years ago

2.4.0

5 years ago

2.3.7

6 years ago

2.3.6

6 years ago

2.3.5

6 years ago

2.3.4

6 years ago

2.3.3

6 years ago

2.3.2

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.32

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago