Skip to content

Commit

Permalink
feat: use @eggjs/static
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 12, 2025
1 parent f7df56e commit a9857a7
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 18 deletions.
1 change: 0 additions & 1 deletion index-old.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
// import 'egg-security';
// import 'egg-logrotator';
// import '@eggjs/schedule';
// import 'egg-static';
// import 'egg-view';

// declare module 'egg' {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@eggjs/i18n": "^3.0.1",
"@eggjs/jsonp": "^3.0.0",
"@eggjs/schedule": "^5.0.2",
"@eggjs/static": "^3.0.0",
"@eggjs/utils": "^4.2.4",
"@eggjs/watcher": "^4.0.3",
"circular-json-for-egg": "^1.0.0",
Expand All @@ -37,7 +38,6 @@
"egg-onerror": "^2.1.1",
"egg-security": "^3.0.0",
"egg-session": "^3.3.0",
"egg-static": "^2.2.0",
"egg-view": "^2.1.3",
"extend2": "^4.0.0",
"graceful": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions site/docs/basics/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ Specific consolidation rules can be found in [Configuration](./config.md).
  - [security](https://github.com/eggjs/egg-security) Security
  - [development](https://github.com/eggjs/development) Development Environment Configuration
  - [logrotator](https://github.com/eggjs/egg-logrotator) Log segmentation
  - [schedule](https://github.com/eggjs/egg-schedule) Timing tasks
  - [static](https://github.com/eggjs/egg-static) Static server
  - [schedule](https://github.com/eggjs/schedule) Timing tasks
  - [static](https://github.com/eggjs/static) Static server
  - [jsonp](https://github.com/eggjs/jsonp) jsonp support
  - [view](https://github.com/eggjs/egg-view) Template Engine
- More community plugins can be found on GitHub [egg-plugin](https://github.com/topics/egg-plugin).
Expand Down
4 changes: 2 additions & 2 deletions site/docs/basics/plugin.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ exports.mysql = {
- [security](https://github.com/eggjs/egg-security) 安全
- [development](https://github.com/eggjs/development) 开发环境配置
- [logrotator](https://github.com/eggjs/egg-logrotator) 日志切分
- [schedule](https://github.com/eggjs/egg-schedule) 定时任务
- [static](https://github.com/eggjs/egg-static) 静态服务器
- [schedule](https://github.com/eggjs/schedule) 定时任务
- [static](https://github.com/eggjs/static) 静态服务器
- [jsonp](https://github.com/eggjs/jsonp) jsonp 支持
- [view](https://github.com/eggjs/egg-view) 模板引擎
- 更多社区的插件可以在 GitHub 上搜索 [egg-plugin](https://github.com/topics/egg-plugin)
Expand Down
4 changes: 2 additions & 2 deletions site/docs/basics/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ As above, directories by conventions of framework:
- `app/controller/**` used to parse the input from user, return the corresponding results after processing, see [Controller](./controller.md) for details.
- `app/service/**` used for business logic layer, optional, recommend to use,see [Service](./service.md) for details.
- `app/middleware/**` uesd for middleware, optional, see [Middleware](./middleware.md) for details.
- `app/public/**` used to place static resources, optional, see built-in plugin [egg-static](https://github.com/eggjs/egg-static) for details.
- `app/public/**` used to place static resources, optional, see built-in plugin [@eggjs/static](https://github.com/eggjs/static) for details.
- `app/extend/**` used for extensions of the framework, optional, see [Extend EGG](./extend.md) for details.
- `config/config.{env}.js` used to write configuration files, see [Configuration](./config.md) for details.
- `config/plugin.js` used to configure the plugins that need to be loaded, see [Plugin](./plugin.md) for details.
Expand All @@ -60,7 +60,7 @@ As above, directories by conventions of framework:

Directories by conventions of built-in plugins:

- `app/public/**` used to place static resources, optional, see built-in plugin [egg-static](https://github.com/eggjs/egg-static) for details.
- `app/public/**` used to place static resources, optional, see built-in plugin [@eggjs/static](https://github.com/eggjs/static) for details.
- `app/schedule/**` used for scheduled tasks, optional, see [Scheduled Task](./schedule.md) for details.

**To customize your own directory specification, see [Loader API](../advanced/loader.md)**
Expand Down
5 changes: 2 additions & 3 deletions site/docs/basics/structure.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ egg-project
- `app/controller/**` 用于解析用户的输入,处理后返回相应的结果,具体参见 [Controller](./controller.md)
- `app/service/**` 用于编写业务逻辑层,建议使用,具体参见 [Service](./service.md)
- `app/middleware/**` 用于编写中间件,具体参见 [Middleware](./middleware.md)
- `app/public/**` 用于放置静态资源,具体参见内置插件 [egg-static](https://github.com/eggjs/egg-static)
- `app/public/**` 用于放置静态资源,具体参见内置插件 [@eggjs/static](https://github.com/eggjs/static)
- `app/extend/**` 用于框架的扩展,具体参见 [框架扩展](./extend.md)
- `config/config.{env}.js` 用于编写配置文件,具体参见 [配置](./config.md)
- `config/plugin.js` 用于配置需要加载的插件,具体参见 [插件](./plugin.md)
- `test/**` 用于单元测试,具体参见 [单元测试](../core/unittest.md)
- `app.js``agent.js` 用于自定义启动时的初始化工作,具体参见 [启动自定义](./app-start.md)。关于 `agent.js` 的作用,参见 [Agent 机制](../core/cluster-and-ipc.md#agent-机制)


由内置插件约定的目录:

- `app/public/**` 用于放置静态资源,具体参见内置插件 [egg-static](https://github.com/eggjs/egg-static)
- `app/public/**` 用于放置静态资源,具体参见内置插件 [@eggjs/static](https://github.com/eggjs/static)
- `app/schedule/**` 用于定时任务,具体参见 [定时任务](./schedule.md)

**若需自定义自己的目录规范,参见 [Loader API](https://eggjs.org/zh-cn/advanced/loader.html)**
Expand Down
6 changes: 3 additions & 3 deletions site/docs/intro/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ open http://localhost:7001
### Adding Static Assets

Egg has a built-in plugin called [static][egg-static].
Egg has a built-in plugin called [static][@eggjs/static].
In production, it is recommended that you deploy static assets to CDN instead of using this plugin.

[static][egg-static] maps `/public/*` to the directory `app/public/*` by default.
[static][@eggjs/static] maps `/public/*` to the directory `app/public/*` by default.

In this case, we just need to put our static assets into the directory `app/public`.

Expand Down Expand Up @@ -476,7 +476,7 @@ Where to go from here? read our documentation to better understand the framework

[node.js]: http://nodejs.org
[egg-bin]: https://github.com/eggjs/egg-bin
[egg-static]: https://github.com/eggjs/egg-static
[@eggjs/static]: https://github.com/eggjs/static
[@eggjs/development]: https://github.com/eggjs/development
[egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks
[nunjucks]: https://mozilla.github.io/nunjucks/
4 changes: 2 additions & 2 deletions site/docs/intro/quickstart.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ $ open http://localhost:7001
### 静态资源

Egg 内置了 [static][egg-static] 插件,线上环境建议部署到 CDN,无需该插件。
Egg 内置了 [static][@eggjs/static] 插件,线上环境建议部署到 CDN,无需该插件。

static 插件默认映射 `/public/* -> app/public/*` 目录。

Expand Down Expand Up @@ -456,7 +456,7 @@ $ npm test

[node.js]: http://nodejs.org
[egg-bin]: https://github.com/eggjs/egg-bin
[egg-static]: https://github.com/eggjs/egg-static
[@eggjs/static]: https://github.com/eggjs/static
[@eggjs/development]: https://github.com/eggjs/development
[egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks
[urllib]: https://www.npmjs.com/package/urllib
Expand Down
2 changes: 1 addition & 1 deletion site/docs/tutorials/assets.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ exports.assets = {

**注意**:此处添加了 `SET_PUBLIC_PATH` 变量,因为 roadhog 这样才能开启 publicPath。

构建的结果根据 `.webpackrc` 配置的 output 决定,示例中是放到 `app/public` 目录下,由 `egg-static` 提供服务。
构建的结果根据 `.webpackrc` 配置的 output 决定,示例中是放到 `app/public` 目录下,由 `@eggjs/static` 提供服务。

同时根据 `.webpackrc` 配置的 manifest 生成一个 `manifest.json` 文件到 `config` 目录下(Egg 读取此文件作为映射关系)。

Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default {
*/
static: {
enable: true,
package: 'egg-static',
package: '@eggjs/static',
},

/**
Expand Down
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '@eggjs/watcher';
import '@eggjs/development';
import '@eggjs/jsonp';
import '@eggjs/i18n';
import '@eggjs/static';

export type {
EggAppInfo,
Expand Down

0 comments on commit a9857a7

Please sign in to comment.