-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: aPPDevTool 获取 resourceDir 适配vue-cli、vite
APPDevTool 获取 resourceDir 适配vue-cli、vite
- Loading branch information
Showing
7 changed files
with
50 additions
and
9 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
33 changes: 33 additions & 0 deletions
33
for-vue2/src/packages/plugins/APPDevTool/common/getResourcePath.ts
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,33 @@ | ||
import { resolve } from 'path'; | ||
import { checkPathExists, err } from '../utils.js'; | ||
import type { Config } from '../config.js'; | ||
|
||
export default function getResourcePath( | ||
userConfig: Config, | ||
): string { | ||
const CLI_DEV_RESOURCE_PATH = resolve(process.cwd(), './dist/dev/app-plus'); | ||
const VITE_DEV_RESOURCE_PATH = resolve(process.cwd(), './dist/dev/app'); | ||
|
||
const CLI_BUILD_RESOURCE_PATH = resolve(process.cwd(), './dist/build/app-plus'); | ||
const VITE_BUILD_RESOURCE_PATH = resolve(process.cwd(), './dist/build/app'); | ||
|
||
if (userConfig.resourceDir) { | ||
return userConfig.resourceDir; | ||
} | ||
|
||
if (process.env.H_UNI_APPDEVTOOL_ENV === 'development') { | ||
// vue-cli | ||
if (checkPathExists(CLI_DEV_RESOURCE_PATH)) return CLI_DEV_RESOURCE_PATH; | ||
// vite | ||
if (checkPathExists(VITE_DEV_RESOURCE_PATH)) return VITE_DEV_RESOURCE_PATH; | ||
} | ||
|
||
if (process.env.H_UNI_APPDEVTOOL_ENV === 'production') { | ||
// vue-cli | ||
if (checkPathExists(CLI_BUILD_RESOURCE_PATH)) return CLI_BUILD_RESOURCE_PATH; | ||
// vite | ||
if (checkPathExists(VITE_BUILD_RESOURCE_PATH)) return VITE_BUILD_RESOURCE_PATH; | ||
} | ||
|
||
return err('未能正确获取 APP 资源目录') as string; | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as initTemplate } from './initTemplate.js'; | ||
export { default as help } from './help.js'; | ||
export { default as getConfig } from './getConfig.js'; | ||
export { default as getResourcePath } from './getResourcePath.js'; |
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,11 @@ | ||
declare global { | ||
namespace NodeJS { | ||
export interface ProcessEnv { | ||
H_UNI_APPDEVTOOL_ENV: 'production' | 'development'; | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
export { }; |
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