目录
semantic-release-bot

Release 3.0.0

[skip ci]

3.0.0 (2025-01-12)

⚠ BREAKING CHANGES

  • drop Node.js < 18.19.0 support

part of https://github.com/eggjs/egg/issues/3644

https://github.com/eggjs/egg/issues/5257

Summary by CodeRabbit

  • New Features

    • Updated package to @eggjs/static
    • Enhanced TypeScript support
    • Improved static file serving configuration
  • Chores

    • Updated GitHub Actions workflows
    • Modernized project configuration
    • Updated Node.js version support to 18.19.0, 20, and 22
  • Documentation

    • Updated README with new package details
    • Simplified changelog and documentation
  • Refactor

    • Migrated from CommonJS to ES modules
    • Restructured project file organization

Features

  • support cjs and esm both by tshy (#26) (ab7d6fb)
1年前39次提交

@eggjs/static

NPM version Node.js CI Test coverage 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.

关于
140.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号