You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modify Vite config before it's resolved. The hook receives the raw user config (CLI options merged with config file). It can return a partial config object that will be deeply merged into existing config, or directly mutate the config (if the default merging cannot achieve the desired result).
117
+
Modify Vite config before it's resolved. The hook receives the raw user config (CLI options merged with config file) and the current config env which exposes the `mode` and `command` being used. It can return a partial config object that will be deeply merged into existing config, or directly mutate the config (if the default merging cannot achieve the desired result).
118
118
119
119
**Example**
120
120
@@ -132,8 +132,10 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo
132
132
// mutate the config directly (use only when merging doesn't work)
133
133
constmutateConfigPlugin= () => ({
134
134
name:'mutate-config',
135
-
config(config) {
136
-
config.root=__dirname
135
+
config(config, { command }) {
136
+
if (command ==='build') {
137
+
config.root=__dirname
138
+
}
137
139
}
138
140
})
139
141
```
@@ -410,8 +412,8 @@ Vite normalizes paths while resolving ids to use POSIX separators ( / ) while pr
410
412
So, for Vite plugins, when comparing paths against resolved ids it is important to first normalize the paths to use POSIX separators. An equivalent `normalizePath` utility function is exported from the `vite` module.
0 commit comments