@reactseed/devserver

1.2.1 • Public • Published

@reactseed/devserver

LICENSE npm version download-image

Override webpack devServer configuration for create-react-app 2.0 order to support mockServer.

How to install

This project relies on react-app-rewiredcustomize-cra. You'll need to install that in order for @reactseed/devserver to work.

yarn add customize-cra react-app-rewired @reactseed/devserver --dev

Usage

Configure customize-cra

/* config-overrides.js */
const { overrideDevServer } = require('customize-cra');
const devServer = require('@reactseed/devserver');

module.exports = {
    devServer: overrideDevServer(devServer),
};

Conventional Mock file

Conventions All files in the /mock folder are mock files except files whose file name starts with _.

.
├── mock
    ├── _constant.js
    └── app.js
└── src

Write Mock files

/* _constant.js */
module.exports = {
  apiPrefix: '/api',
};
/* app.js */
const { apiPrefix } = require('./_constant');
const packageJSON = require('../package.json');

module.exports = {
  [`GET ${apiPrefix}/app`]: packageJSON,
};

Visit /api/app to get a response.

Readme

Keywords

Package Sidebar

Install

npm i @reactseed/devserver

Weekly Downloads

3

Version

1.2.1

License

BSD

Unpacked Size

6.22 kB

Total Files

5

Last publish

Collaborators

  • reactseed