Skip to content

Commit

Permalink
fix: generate config
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Oct 19, 2023
1 parent 227f270 commit 58cc3bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/utils/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { version } from "../../../package.json";
import type { GlobConfig, GlobEnvConfig } from "#/config";

function sanitizeString(str: string): string {
// Replace invalid characters with an empty string
const sanitized = str.replace(/[^\w.-]/g, "");
// Trim any remaining whitespace
return sanitized.trim().replace(/-/g, "__");
}

/**
* Get the configuration file variable name
* @param env
*/
export function getAppConfigFileName(env: GlobEnvConfig): string {
const shortName: string = env?.VITE_GLOB_APP_SHORT_NAME || "__APP";
const shortName: string = sanitizeString(env?.VITE_GLOB_APP_SHORT_NAME || "__APP");
return `__PRODUCTION__${shortName}__CONF__`.toUpperCase().replace(/\s/g, "");
}

Expand Down
2 changes: 1 addition & 1 deletion vite-config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const GLOB_CONFIG_FILE_NAME = "_app.config.js";
export const OUTPUT_DIR = "dist";

// This constant sets the name of the application
export const APP_NAME = "boot-vant";
export const APP_NAME = "BootVant";

0 comments on commit 58cc3bd

Please sign in to comment.