File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
import fs from 'fs' ;
2
2
import path from 'path' ;
3
- import type { Plugin } from 'vite' ;
3
+ import type { Plugin , ResolvedConfig } from 'vite' ;
4
4
5
5
export function createEnvConfigContent ( variables : string [ ] , template : boolean ) : string {
6
6
let templateContent = '' ;
@@ -26,12 +26,12 @@ export interface EnvConfigOptions {
26
26
}
27
27
28
28
export function envConfig ( userOptions : Partial < EnvConfigOptions > = { } ) : Plugin {
29
- let root : string ;
29
+ let config : ResolvedConfig ;
30
30
return {
31
31
name : 'vite-plugin-env-config' ,
32
32
33
- configResolved ( config ) {
34
- root = config . root ;
33
+ configResolved ( resolvedConfig ) {
34
+ config = resolvedConfig ;
35
35
} ,
36
36
37
37
configureServer ( server ) {
@@ -55,7 +55,7 @@ export function envConfig(userOptions: Partial<EnvConfigOptions> = {}): Plugin {
55
55
closeBundle ( ) {
56
56
const templateContent = createEnvConfigContent ( userOptions . variables || [ ] , true ) ;
57
57
58
- const TEMPLATE_PATH = path . join ( root , 'dist' , 'env-config.template.js' ) ;
58
+ const TEMPLATE_PATH = path . join ( config . root , config . build . outDir , 'env-config.template.js' ) ;
59
59
fs . mkdirSync ( path . dirname ( TEMPLATE_PATH ) , { recursive : true } ) ;
60
60
fs . writeFileSync ( TEMPLATE_PATH , templateContent , 'utf8' ) ;
61
61
} ,
You can’t perform that action at this time.
0 commit comments