@neutrinojs/start-server
is Neutrino middleware for starting a Node.js server for a file upon
completion of a build.
- Node.js v6 LTS, v8, v9
- Yarn v1.2.1+, or npm v5.4+
- Neutrino v8
@neutrinojs/start-server
can be installed via the Yarn or npm clients.
❯ yarn add @neutrinojs/start-server
❯ npm install --save @neutrinojs/start-server
@neutrinojs/start-server
can be consumed from the Neutrino API, middleware, or presets. Require this package
and plug it into Neutrino:
// Using function middleware format
const server = require('@neutrinojs/start-server');
// Use with default options, starting the server
// for the main entry point, defaults to neutrino.options.mains.index
neutrino.use(server);
// Usage with custom server file to start
neutrino.use(server, {
name: 'custom.js',
// Override pluginId to add an additional start-server plugin instance
pluginId: 'start-server'
});
// Using object or array middleware format
// Use with default options, starting the server
// for the main entry point, defaults to neutrino.options.mains.index
module.exports = {
use: ['@neutrinojs/start-server']
};
// Usage with custom server file to start
module.exports = {
use: [
['@neutrinojs/start-server', {
name: 'custom.js',
// Override pluginId to add an additional start-server plugin instance
pluginId: 'start-server'
}]
]
};
By default this middleware will start a server with the first main entry point configured in Neutrino, by default
src/index
. This middleware optionally accepts an object with a name
property for a path to a module which to
start the server.
@neutrinojs/start-server
creates some conventions to make overriding the configuration easier once you are
ready to make changes.
The following is a list of plugins and their identifiers which can be overridden:
Name | Description | Environments and Commands |
---|---|---|
start-server |
Start a Node.js for the first configured main entry point or specified file. | all |
You can start the Node.js server in inspect
mode to debug the process by setting neutrino.options.debug
to true
.
This can be done from the API or the
CLI using --debug
.
This middleware is part of the neutrino-dev repository, a monorepo containing all resources for developing Neutrino and its core presets and middleware. Follow the contributing guide for details.