-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
背景
目前 build-scripts 工程工具应用于 icejs、rax-app 等框架体系,框架中内置了大量的插件及其功能。而对于三方插件其执行顺序永远在内置插件之后,对于一些强制依赖所有配置完成修改后的能力(如 rax-app wirteToDisk 配置依赖 outputDir 的设置)将会出现失效的情况。因此希望能提供一些机制动态设置插件执行顺序
技术方案
目前插件的规范是以默认导出的 JavaScript 模块的方式导出:
// esm
export default () => {}
// cjs
module.exports = () => {}
通过导出规范的约束,增加执行顺序的设置
// esm
export default {
plugin: () => {},
enforce: 'pre'
}
// cjs
module.exports = {
plugin: () => {},
enfore: 'pre'
}
enforce 可选值为 pre(前置执行)、normal(默认)、post(后置执行)
执行顺序如下:
- 执行设置 enforce 为 pre 的插件
- 执行设置 enforce 为 normal 的插件和现有默认导出的插件
- 执行设置 enforce 为 post 的插件
Metadata
Metadata
Assignees
Labels
No labels