-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(module): add custom esbuild plugin example (#4228)
* docs(module): add custom esbuild plugin example * docs: update
- Loading branch information
1 parent
21be212
commit 042843f
Showing
8 changed files
with
95 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/document/module-doc/docs/en/components/register-esbuild-plugin.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```js modern.config.ts | ||
import { myEsbuildPlugin } from './myEsbuildPlugin'; | ||
|
||
export default defineConfig({ | ||
buildConfig: { | ||
esbuildOptions: options => { | ||
options.plugins = [myEsbuildPlugin, ...options.plugins]; | ||
return option; | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
When adding an esbuild plugin, please note that you need to add the plugin at the beginning of the plugins array. This is because the Modern.js Module is also integrated into the entire build process through an esbuild plugin. Therefore, custom plugins need to be registered with higher priority. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/document/module-doc/docs/zh/components/register-esbuild-plugin.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```js modern.config.ts | ||
import { myEsbuildPlugin } from './myEsbuildPlugin'; | ||
|
||
export default defineConfig({ | ||
buildConfig: { | ||
esbuildOptions: options => { | ||
options.plugins = [myEsbuildPlugin, ...options.plugins]; | ||
return option; | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
在增加 esbuild 插件时,请注意你需要将插件加在 plugins 数组的头部,因为 Modern.js Module 内部也是通过一个 esbuild 插件介入到整个构建流程中去的,因此需要将自定义插件优先注册。 |
Oops, something went wrong.