File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
builder-vite/src/features
builder-webpack/src/plugins/features Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export default (api: IPluginAPI) => {
88 const versionPlugin = {
99 name : 'fes-version-emit' ,
1010 generateBundle ( ) {
11- const pkgPath = join ( process . cwd ( ) , 'package.json' ) ;
11+ const pkgPath = join ( api . paths . cwd , 'package.json' ) ;
1212 let name = '' ;
1313 let version = '' ;
1414 if ( existsSync ( pkgPath ) ) {
Original file line number Diff line number Diff line change @@ -5,10 +5,11 @@ import process from 'node:process';
55import webpack from 'webpack' ;
66
77class VersionEmitPlugin {
8+ constructor ( private cwd : string ) { }
89 apply ( compiler : webpack . Compiler ) {
910 compiler . hooks . thisCompilation . tap ( 'VersionEmitPlugin' , ( compilation ) => {
1011 compilation . hooks . processAssets . tap ( { name : 'VersionEmitPlugin' , stage : webpack . Compilation . PROCESS_ASSETS_STAGE_ADDITIONAL } , ( ) => {
11- const pkgPath = join ( process . cwd ( ) , 'package.json' ) ;
12+ const pkgPath = join ( this . cwd , 'package.json' ) ;
1213 let name = '' ;
1314 let version = '' ;
1415 if ( existsSync ( pkgPath ) ) {
@@ -41,7 +42,7 @@ class VersionEmitPlugin {
4142export default ( api : IPluginAPI ) => {
4243 api . modifyBundleConfig ( ( memo : any ) => {
4344 memo . plugins = memo . plugins || [ ] ;
44- memo . plugins . push ( new VersionEmitPlugin ( ) ) ;
45+ memo . plugins . push ( new VersionEmitPlugin ( api . paths . cwd ) ) ;
4546 return memo ;
4647 } ) ;
4748} ;
You can’t perform that action at this time.
0 commit comments