relient-cli
Relient CLI is a cli wrapper of react-starter-kit. It also provides configuration and API mock tools.
Last updated a month ago by zation .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install relient-cli 
SYNC missed versions from official npm registry.

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,
  },
}

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' }]);
  });
}

Current Tags

  • 2.6.3                                ...           latest (a month ago)

59 Versions

  • 2.6.3                                ...           a month ago
  • 2.6.2                                ...           a month ago
  • 2.6.1                                ...           4 months ago
  • 2.6.0                                ...           4 months ago
  • 2.5.0                                ...           8 months ago
  • 2.4.0                                ...           10 months ago
  • 2.3.7                                ...           a year ago
  • 2.3.6                                ...           a year ago
  • 2.3.5                                ...           a year ago
  • 2.3.4                                ...           a year ago
  • 2.3.3                                ...           a year ago
  • 2.3.2                                ...           a year ago
  • 2.3.0                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.34                                ...           2 years ago
  • 0.0.33                                ...           2 years ago
  • 0.0.32                                ...           2 years ago
  • 0.0.31                                ...           2 years ago
  • 0.0.30                                ...           2 years ago
  • 0.0.29                                ...           2 years ago
  • 0.0.28                                ...           2 years ago
  • 0.0.27                                ...           2 years ago
  • 0.0.26                                ...           2 years ago
  • 0.0.25                                ...           2 years ago
  • 0.0.24                                ...           2 years ago
  • 0.0.23                                ...           2 years ago
  • 0.0.22                                ...           2 years ago
  • 0.0.21                                ...           2 years ago
  • 0.0.20                                ...           2 years ago
  • 0.0.19                                ...           2 years ago
  • 0.0.18                                ...           2 years ago
  • 0.0.17                                ...           2 years ago
  • 0.0.16                                ...           2 years ago
  • 0.0.15                                ...           2 years ago
  • 0.0.14                                ...           2 years ago
  • 0.0.13                                ...           2 years ago
  • 0.0.12                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.10                                ...           2 years ago
  • 0.0.9                                ...           2 years ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 42
Dependencies (69)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |