Skip to content

how to distribute local web server with your project

Lloyd Brookes edited this page Jul 8, 2017 · 2 revisions

The standard convention with server applications is to add an npm start command to launch the server.

  1. Install the server as a dev dependency

    $ npm install local-web-server --save-dev
  2. Include the preferred config with your project, for example

    // lws.config.js
    
    module.exports = {
      port: 8050,
      rewrite: [
        {
          from: '/api/*',
          to: 'http://api-server:8080/api/$1',
        }
      ],
      directory: 'src'
    }
  3. Add a start command to your package.json:

    {
      "scripts": {
        "start": "ws"
      }
    }
  4. Document how to build and launch your site

    $ npm install
    $ npm start
    Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:8000
Clone this wiki locally