Newton's Programmatic Measurements
    Have ideas to improve npm?Join in the discussion! »

    @neutrinojs/start-server

    9.5.0 • Public • Published

    Neutrino Start Server Middleware

    @neutrinojs/start-server is Neutrino middleware for starting a Node.js server for a file upon completion of a build.

    NPM version NPM downloads

    Requirements

    • Node.js 10+
    • Yarn v1.2.1+, or npm v5.4+
    • Neutrino 9
    • webpack 4

    Installation

    @neutrinojs/start-server can be installed via the Yarn or npm clients.

    Yarn

    ❯ yarn add --dev @neutrinojs/start-server

    npm

    ❯ npm install --save-dev @neutrinojs/start-server

    Usage

    @neutrinojs/start-server can be consumed from the Neutrino API, middleware, or presets. Require this package and plug it into Neutrino:

    const startServer = require('@neutrinojs/start-server');
    
    // Use with default options, starting the server
    // for the main entry point, defaults to neutrino.options.mains.index
    neutrino.use(startServer());
    
    // Usage with custom server file to start
    neutrino.use(
      startServer({
        name: 'custom.js',
        // Override pluginId to add an additional start-server plugin instance
        pluginId: 'start-server',
      }),
    );
    // Using in .neutrinorc.js
    const startServer = require('@neutrinojs/start-server');
    
    // Use with default options, starting the server
    // for the main entry point, defaults to neutrino.options.mains.index
    module.exports = {
      use: [startServer()],
    };
    
    // Usage with custom server file to start
    module.exports = {
      use: [
        startServer({
          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.

    Customization

    @neutrinojs/start-server creates some conventions to make overriding the configuration easier once you are ready to make changes.

    Plugins

    The following is a list of plugins and their identifiers which can be overridden:

    Name Description NODE_ENV
    start-server Start a Node.js for the first configured main entry point or specified file. all

    Debugging

    You can start the Node.js server in inspect mode to debug the process by setting neutrino.options.debug to true.

    Contributing

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

    Install

    npm i @neutrinojs/start-server

    DownloadsWeekly Downloads

    569

    Version

    9.5.0

    License

    MPL-2.0

    Unpacked Size

    21 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar