You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
constgen 0bfe158028 Let dev server middleware to decide when to initialize 8 years ago
..
README.md Add customization documentation 8 years ago
index.js Let dev server middleware to decide when to initialize 8 years ago
package.json Merge branch 'master' into feature/dev-server-ip 8 years ago
yarn.lock Exclude hot reload functionality from the web preset 8 years ago

README.md

Neutrino Dev Server Middleware

NPM version NPM downloads Join Slack

neutrino-middleware-dev-server is Neutrino middleware for starting a Webpack Dev Server for fast development cycles.

Requirements

  • Node.js v6.9+
  • Yarn or npm client
  • Neutrino v5

Installation

neutrino-middleware-dev-server can be installed via the Yarn or npm clients.

Yarn

❯ yarn add neutrino-middleware-dev-server

npm

❯ npm install --save neutrino-middleware-dev-server

Usage

neutrino-middleware-dev-server can be consumed from the Neutrino API, middleware, or presets. Require this package and plug it into Neutrino:

const devServer = require('neutrino-middleware-dev-server');

// Usage with default options
neutrino.use(devServer);

// Usage with custom options (default options are shown)
neutrino.use(devServer, { 
  public: false,
  https: false,
  port: 5000,
  open: false
});

By default this middleware will start a development server with the hot reload support on http://localhost:5000. To enable Hot Module Replacement read the documentation of your framework of choise or documentation of corresponding Neutrino preset or middlware.

It is recommended to call this middlware only in development mode when process.env.NODE_ENV === 'development'. More imformation about usage of Neutrino middlwares can be found in the documentation.

Configuration

neutrino-middleware-dev-server optionally accepts an object with several options to override the default behavior.

  • public: Optional boolean value that makes the server accessible in local network using current machine local IP. Default is false.
  • https: Optional boolean value that swithches hosting to HTTPS protocol with fake certificate. Default is false.
  • port: Optional naumber value of the custom port. Default is 5000.
  • open: Optional boolean value to open the project in the new tab of the default browser. Default is false.

Customization

neutrino-middleware-dev-server creates some conventions to make overriding the configuration easier for the end consumer that setups his project. All parameters are optional and can be configured in the package.json:

{
  ...
  "neutrino": {
    "use": [...],
    "options": {
      "server": {
        "public": true,
        "open": true,
        "https": true,
        "port": 4000
      }
    }
  },
  ...
}

Contributing

This preset is part of the neutrino-dev repository, a monorepo containing all resources for developing Neutrino and its core presets. Follow the contributing guide for details.