egg-static
static server plugin for egg
Last updated 7 years ago by dead_horse .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install egg-static 
SYNC missed versions from official npm registry.

egg-static

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Static server plugin for egg, base on koa-static-cache.

Install

$ npm i egg-static --save

Usage

egg-static is a plugin that has been built-in for egg. But it is disabled by default.

// {app_root}/config/plugin.js
exports.static = true;

Configuration

egg-static support all configurations in koa-static-cache. and with default configurations below:

  • prefix: /public/
  • dir: path.join(appInfo.baseDir, 'app/public')
  • dynamic: true
  • preload: false
  • maxAge: 31536000 in prod env, 0 in other envs
  • buffer: true in prod env, false in other envs

egg-static provides one more option:

  • maxFiles: the maximum value of cache items, only effective when dynamic is true, default is 1000.

All static files in $baseDir/app/public can be visited with prefix /public, and all the files are lazy loaded.

  • In non-production environment, assets won't be cached, your modification can take effect immediately.
  • In production environment, egg-static will cache the assets after visited, you need to restart the process to update the assets.
  • Dir default is $baseDir/app/public but you can also define multiple directory by use dir: [dir1, dir2, ...] and static server will use all these directories.
// {app_root}/config/config.default.js
exports.static = {
  // maxAge: 31536000,
};

Questions & Suggestions

Please open an issue here.

License

MIT

Current Tags

  • 2.3.1                                ...           latest (2 years ago)
  • 1.5.1                                ...           latest-1 (7 years ago)

17 Versions

  • 2.3.1                                ...           2 years ago
  • 2.3.0                                ...           2 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.1                                ...           7 years ago
  • 1.5.1                                ...           7 years ago
  • 1.5.0                                ...           7 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.4.1                                ...           7 years ago
  • 1.4.0                                ...           7 years ago
  • 1.3.0                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (9)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE