@eggjs/static
static server plugin for egg
Last updated a year ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @eggjs/static 
SYNC missed versions from official npm registry.

@eggjs/static

NPM version Known Vulnerabilities npm download Node.js Version PRs Welcome

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

Install

@eggjs/static is a plugin that has been built-in for egg. It is enabled by default.

Configuration

@eggjs/static support all configurations in @eggjs/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

@eggjs/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, @eggjs/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, ...] or dir: [dir1, { prefix: '/static2', dir: dir2 }], static server will use all these directories.
// {app_root}/config/config.default.ts
export default {
  static: {
    // maxAge: 31536000,
  },
};

Questions & Suggestions

Please open an issue here.

License

MIT

Contributors

Contributors

Made with contributors-img.

Current Tags

  • 4.0.2-beta.27                                ...           beta (2 months ago)
  • 4.1.0                                ...           latest (2 months ago)
  • 4.0.2-rc.1                                ...           rc (2 months ago)

54 Versions

  • 4.1.0                                ...           2 months ago
  • 4.0.2                                ...           2 months ago
  • 4.0.2-rc.1                                ...           2 months ago
  • 4.0.2-rc.0                                ...           2 months ago
  • 4.0.2-beta.27                                ...           2 months ago
  • 4.0.2-beta.26                                ...           4 months ago
  • 4.0.2-beta.25                                ...           4 months ago
  • 4.0.2-beta.24                                ...           4 months ago
  • 4.0.2-beta.23                                ...           5 months ago
  • 4.0.2-beta.22                                ...           5 months ago
  • 4.0.2-beta.20                                ...           5 months ago
  • 4.0.2-beta.19                                ...           5 months ago
  • 4.0.2-beta.17                                ...           5 months ago
  • 4.0.2-beta.16                                ...           5 months ago
  • 4.0.2-beta.15                                ...           5 months ago
  • 4.0.2-beta.14                                ...           5 months ago
  • 4.0.2-beta.13                                ...           5 months ago
  • 4.0.2-beta.12                                ...           5 months ago
  • 4.0.2-beta.11                                ...           5 months ago
  • 4.0.2-beta.10                                ...           5 months ago
  • 4.0.2-beta.9                                ...           8 months ago
  • 4.0.2-beta.8                                ...           8 months ago
  • 4.0.2-beta.7                                ...           8 months ago
  • 4.0.2-beta.6                                ...           8 months ago
  • 4.0.2-beta.5                                ...           8 months ago
  • 4.0.2-beta.4                                ...           8 months ago
  • 4.0.2-beta.3                                ...           9 months ago
  • 4.0.2-beta.2                                ...           9 months ago
  • 4.0.2-beta.1                                ...           9 months ago
  • 4.0.2-beta.0                                ...           9 months ago
  • 4.0.1-beta.0                                ...           9 months ago
  • 4.0.0-beta.36                                ...           a year ago
  • 4.0.0-beta.35                                ...           a year ago
  • 4.0.0-beta.34                                ...           a year ago
  • 4.0.0-beta.33                                ...           a year ago
  • 4.0.0-beta.32                                ...           a year ago
  • 4.0.0-beta.31                                ...           a year ago
  • 4.0.0-beta.30                                ...           a year ago
  • 4.0.0-beta.29                                ...           a year ago
  • 4.0.0-beta.28                                ...           a year ago
  • 4.0.0-beta.27                                ...           a year ago
  • 4.0.0-beta.26                                ...           a year ago
  • 4.0.0-beta.25                                ...           a year ago
  • 4.0.0-beta.24                                ...           a year ago
  • 4.0.0-beta.23                                ...           a year ago
  • 4.0.0-beta.22                                ...           a year ago
  • 4.0.0-beta.21                                ...           a year ago
  • 4.0.0-beta.20                                ...           a year ago
  • 4.0.0-beta.19                                ...           a year ago
  • 4.0.0-beta.18                                ...           a year ago
  • 4.0.0-beta.17                                ...           a year ago
  • 4.0.0-beta.15                                ...           a year ago
  • 4.0.0-beta.13                                ...           a year ago
  • 3.0.0                                ...           2 years ago
Downloads
Total 122
Today 3
This Week 36
This Month 111
Last Day 1
Last Week 61
Last Month 1
Dependencies (4)
Dev Dependencies (8)
Dependents (1)

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