All Projects → electrode-io → Electrode Static Paths

electrode-io / Electrode Static Paths

Licence: other
Electrode server decor to serve static files

Programming Languages

javascript
184084 projects - #8 most used programming language

Electrode Static Paths

NPM version Build Status Dependency Status

Electrode Server Decor to serve static files using inert.

Usage

Install

$ npm i electrode-static-paths --save
const electrodeServer = require("electrode-server");

electrodeServer( config, [require("electrode-static-paths")()] );

Static Files

By default, the static files are served from dist under CWD.

  • Route /html will serve files from dist/html
  • Route /js will serve files from dist/js
  • Route /images will serve files from dist/images

Route and Path prefixes

You can change the prefix dist with pathPrefix in options to the electrodeStaticPaths plugin.

You can add a route prefix with routePrefix option.

For example:

const config = {
  plugins: {
    electrodeStaticPaths: {
      options: {
        routePrefix: "/test",
        pathPrefix: "myfiles"
      }
    }
  }
};

Routes

You can override the /html, /js, and /images routes with routes option.

For example, if you only want to serve files at /js, then:

{
  plugins: {
    electrodeStaticPaths: {
      options: {
        routes: [ "js" ]
      }
    }
  }
}

Route config

You can also specify configs to be passed to server.route:

const config = {
  plugins: {
    electrodeStaticPaths: {
      options: {
        config: {
        }
      }
    }
  }
};

Built with ❤️ by Team Electrode @WalmartLabs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].