From a9857a7fa7468ae5a4501c105721da65bdb4c475 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 12 Jan 2025 23:30:17 +0800 Subject: [PATCH] feat: use @eggjs/static --- index-old.d.ts | 1 - package.json | 2 +- site/docs/basics/plugin.md | 4 ++-- site/docs/basics/plugin.zh-CN.md | 4 ++-- site/docs/basics/structure.md | 4 ++-- site/docs/basics/structure.zh-CN.md | 5 ++--- site/docs/intro/quickstart.md | 6 +++--- site/docs/intro/quickstart.zh-CN.md | 4 ++-- site/docs/tutorials/assets.zh-CN.md | 2 +- src/config/plugin.ts | 2 +- src/lib/types.ts | 1 + 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/index-old.d.ts b/index-old.d.ts index 22c35cb003..78a0522a72 100644 --- a/index-old.d.ts +++ b/index-old.d.ts @@ -38,7 +38,6 @@ // import 'egg-security'; // import 'egg-logrotator'; // import '@eggjs/schedule'; -// import 'egg-static'; // import 'egg-view'; // declare module 'egg' { diff --git a/package.json b/package.json index 70f5543bd3..8aa1746bed 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/site/docs/basics/plugin.md b/site/docs/basics/plugin.md index c49f27bf92..341a8074c4 100644 --- a/site/docs/basics/plugin.md +++ b/site/docs/basics/plugin.md @@ -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). diff --git a/site/docs/basics/plugin.zh-CN.md b/site/docs/basics/plugin.zh-CN.md index 17d6dd15f3..ff83981da3 100644 --- a/site/docs/basics/plugin.zh-CN.md +++ b/site/docs/basics/plugin.zh-CN.md @@ -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)。 diff --git a/site/docs/basics/structure.md b/site/docs/basics/structure.md index 49dc991ead..24d4a19d8d 100644 --- a/site/docs/basics/structure.md +++ b/site/docs/basics/structure.md @@ -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. @@ -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)** diff --git a/site/docs/basics/structure.zh-CN.md b/site/docs/basics/structure.zh-CN.md index 884426b154..f4505208f7 100644 --- a/site/docs/basics/structure.zh-CN.md +++ b/site/docs/basics/structure.zh-CN.md @@ -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)** diff --git a/site/docs/intro/quickstart.md b/site/docs/intro/quickstart.md index caf4cac843..04892105bf 100644 --- a/site/docs/intro/quickstart.md +++ b/site/docs/intro/quickstart.md @@ -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`. @@ -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/ diff --git a/site/docs/intro/quickstart.zh-CN.md b/site/docs/intro/quickstart.zh-CN.md index 715538a201..711aebb3b2 100644 --- a/site/docs/intro/quickstart.zh-CN.md +++ b/site/docs/intro/quickstart.zh-CN.md @@ -124,7 +124,7 @@ $ open http://localhost:7001 ### 静态资源 -Egg 内置了 [static][egg-static] 插件,线上环境建议部署到 CDN,无需该插件。 +Egg 内置了 [static][@eggjs/static] 插件,线上环境建议部署到 CDN,无需该插件。 static 插件默认映射 `/public/* -> app/public/*` 目录。 @@ -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 diff --git a/site/docs/tutorials/assets.zh-CN.md b/site/docs/tutorials/assets.zh-CN.md index 8f45b979b5..1c3925e773 100644 --- a/site/docs/tutorials/assets.zh-CN.md +++ b/site/docs/tutorials/assets.zh-CN.md @@ -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 读取此文件作为映射关系)。 diff --git a/src/config/plugin.ts b/src/config/plugin.ts index 8ab7bffcef..2e37c58f4e 100644 --- a/src/config/plugin.ts +++ b/src/config/plugin.ts @@ -105,7 +105,7 @@ export default { */ static: { enable: true, - package: 'egg-static', + package: '@eggjs/static', }, /** diff --git a/src/lib/types.ts b/src/lib/types.ts index 0724d2601b..5efbe274ef 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -21,6 +21,7 @@ import '@eggjs/watcher'; import '@eggjs/development'; import '@eggjs/jsonp'; import '@eggjs/i18n'; +import '@eggjs/static'; export type { EggAppInfo,