|
8 years ago | |
---|---|---|
.. | ||
README.md | 8 years ago | |
index.js | 8 years ago | |
package.json | 8 years ago | |
yarn.lock | 8 years ago |
README.md
Neutrino Dev Server Middleware
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 isfalse
.https
: Optional boolean value that swithches hosting to HTTPS protocol with fake certificate. Default isfalse
.port
: Optional naumber value of the custom port. Default is5000
.open
: Optional boolean value to open the project in the new tab of the default browser. Default isfalse
.
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.