Skip to content

Commit

Permalink
docs: clarify enforce vs hook.order (#16226)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens authored Mar 24, 2024
1 parent 6a07243 commit 3a73e48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ A Vite plugin can additionally specify an `enforce` property (similar to webpack
- User plugins with `enforce: 'post'`
- Vite post build plugins (minify, manifest, reporting)

Note that this is separate from hooks ordering, those are still separately subject to their `order` attribute [as usual for Rollup hooks](https://rollupjs.org/plugin-development/#build-hooks).

## Conditional Application

By default plugins are invoked for both serve and build. In cases where a plugin needs to be conditionally applied only during serve or build, use the `apply` property to only invoke them during `'build'` or `'serve'`:
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import type { PreviewServerHook } from './preview'
*/
export interface Plugin<A = any> extends RollupPlugin<A> {
/**
* Enforce plugin invocation tier similar to webpack loaders.
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
* is still subject to the `order` property in the hook object.
*
* Plugin invocation order:
* - alias resolution
Expand Down

0 comments on commit 3a73e48

Please sign in to comment.