mirror of
https://gitee.com/bootx/dax-pay-ui.git
synced 2025-09-06 20:28:00 +00:00
chore: remove useless code
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Get the configuration file variable name
|
||||
* @param env
|
||||
*/
|
||||
export const getShortName = (env: any) => {
|
||||
export const getConfigFileName = (env: Record<string, any>) => {
|
||||
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`
|
||||
.toUpperCase()
|
||||
.replace(/\s/g, '');
|
@@ -5,8 +5,8 @@ import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant';
|
||||
import fs, { writeFileSync } from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
|
||||
import { getCwdPath, getEnvConfig } from '../utils';
|
||||
import { getShortName } from '../getShortName';
|
||||
import { getRootPath, getEnvConfig } from '../utils';
|
||||
import { getConfigFileName } from '../getConfigFileName';
|
||||
|
||||
import pkg from '../../package.json';
|
||||
|
||||
@@ -27,8 +27,8 @@ function createConfig(
|
||||
writable: false,
|
||||
});
|
||||
`.replace(/\s/g, '');
|
||||
fs.mkdirp(getCwdPath(OUTPUT_DIR));
|
||||
writeFileSync(getCwdPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
||||
fs.mkdirp(getRootPath(OUTPUT_DIR));
|
||||
writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
||||
|
||||
console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||
console.log(chalk.gray(OUTPUT_DIR + '/' + chalk.green(configFileName)) + '\n');
|
||||
@@ -39,6 +39,6 @@ function createConfig(
|
||||
|
||||
export function runBuildConfig() {
|
||||
const config = getEnvConfig();
|
||||
const configFileName = getShortName(config);
|
||||
const configFileName = getConfigFileName(config);
|
||||
createConfig({ config, configName: configFileName });
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ export const runBuild = async () => {
|
||||
if (!argvList.includes('no-conf')) {
|
||||
await runBuildConfig();
|
||||
}
|
||||
|
||||
console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
|
||||
} catch (error) {
|
||||
console.log(chalk.red('vite build error:\n' + error));
|
||||
|
@@ -5,7 +5,6 @@
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react",
|
||||
"baseUrl": ".",
|
||||
"esModuleInterop": true,
|
||||
"noUnusedLocals": true,
|
||||
|
2
build/typeing.d.ts
vendored
2
build/typeing.d.ts
vendored
@@ -2,3 +2,5 @@ declare module '*.json' {
|
||||
const src: any;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare type Recordable = Record<string, any>;
|
||||
|
@@ -2,12 +2,6 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
export const isFunction = (arg: unknown): arg is (...args: any[]) => any =>
|
||||
typeof arg === 'function';
|
||||
|
||||
export const isRegExp = (arg: unknown): arg is RegExp =>
|
||||
Object.prototype.toString.call(arg) === '[object RegExp]';
|
||||
|
||||
export function isDevFn(mode: string): boolean {
|
||||
return mode === 'development';
|
||||
}
|
||||
@@ -34,18 +28,18 @@ export interface ViteEnv {
|
||||
VITE_USE_CDN: boolean;
|
||||
VITE_DROP_CONSOLE: boolean;
|
||||
VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
|
||||
VITE_DYNAMIC_IMPORT: boolean;
|
||||
VITE_LEGACY: boolean;
|
||||
VITE_USE_IMAGEMIN: boolean;
|
||||
}
|
||||
|
||||
// Read all environment variable configuration files to process.env
|
||||
export function wrapperEnv(envConf: any): ViteEnv {
|
||||
export function wrapperEnv(envConf: Recordable): ViteEnv {
|
||||
const ret: any = {};
|
||||
|
||||
for (const envName of Object.keys(envConf)) {
|
||||
let realName = envConf[envName].replace(/\\n/g, '\n');
|
||||
realName = realName === 'true' ? true : realName === 'false' ? false : realName;
|
||||
|
||||
if (envName === 'VITE_PORT') {
|
||||
realName = Number(realName);
|
||||
}
|
||||
@@ -70,10 +64,10 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = ['.env', '.env.pr
|
||||
confFiles.forEach((item) => {
|
||||
try {
|
||||
const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)));
|
||||
|
||||
envConfig = { ...envConfig, ...env };
|
||||
} catch (error) {}
|
||||
});
|
||||
|
||||
Object.keys(envConfig).forEach((key) => {
|
||||
const reg = new RegExp(`^(${match})`);
|
||||
if (!reg.test(key)) {
|
||||
@@ -87,6 +81,6 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = ['.env', '.env.pr
|
||||
* Get user root directory
|
||||
* @param dir file path
|
||||
*/
|
||||
export function getCwdPath(...dir: string[]) {
|
||||
export function getRootPath(...dir: string[]) {
|
||||
return path.resolve(process.cwd(), ...dir);
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import type { ViteEnv } from '../../utils';
|
||||
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
@@ -6,7 +7,6 @@ import legacy from '@vitejs/plugin-legacy';
|
||||
|
||||
import PurgeIcons from 'vite-plugin-purge-icons';
|
||||
|
||||
import { ViteEnv } from '../../utils';
|
||||
import { configHtmlPlugin } from './html';
|
||||
import { configPwaConfig } from './pwa';
|
||||
import { configMockPlugin } from './mock';
|
||||
|
@@ -2,11 +2,10 @@
|
||||
* Zero-config PWA for Vite
|
||||
* https://github.com/antfu/vite-plugin-pwa
|
||||
*/
|
||||
import type { ViteEnv } from '../../utils';
|
||||
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
|
||||
import { ViteEnv } from '../../utils';
|
||||
|
||||
export function configPwaConfig(env: ViteEnv) {
|
||||
const { VITE_USE_PWA, VITE_GLOB_APP_TITLE, VITE_GLOB_APP_SHORT_NAME } = env;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import windiCSS from 'vite-plugin-windicss';
|
||||
|
||||
import type { Plugin } from 'vite';
|
||||
|
||||
import windiCSS from 'vite-plugin-windicss';
|
||||
|
||||
export function configWindiCssPlugin(): Plugin[] {
|
||||
return windiCSS({
|
||||
safelist: 'no-select',
|
||||
|
Reference in New Issue
Block a user