Commit 759e5320790504f0d274289001543c1397e8b617

Authored by vben
1 parent a3a903bc

fix: correct debugger code

build/config/themeConfig.ts
1 1 import { generate } from '@ant-design/colors';
2 2  
3   -export const primaryColor = '#0084f4';
  3 +export const primaryColor = '#0960bd';
4 4  
5 5 export const themeMode = 'light';
6 6  
... ...
build/constant.ts
... ... @@ -2,3 +2,5 @@
2 2 * The name of the configuration file entered in the production environment
3 3 */
4 4 export const GLOB_CONFIG_FILE_NAME = '_app.config.js';
  5 +
  6 +export const OUTPUT_DIR = 'dist';
... ...
build/script/buildConf.ts
1 1 /**
2 2 * Generate additional configuration files when used for packaging. The file can be configured with some global variables, so that it can be changed directly externally without repackaging
3 3 */
4   -import { GLOB_CONFIG_FILE_NAME } from '../constant';
  4 +import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant';
5 5 import fs, { writeFileSync } from 'fs-extra';
6 6 import chalk from 'chalk';
7 7  
8 8 import { getCwdPath, getEnvConfig } from '../utils';
9 9 import { getShortName } from '../getShortName';
10 10  
  11 +import pkg from '../../package.json';
  12 +
11 13 function createConfig(
12 14 {
13 15 configName,
... ... @@ -17,21 +19,19 @@ function createConfig(
17 19 ) {
18 20 try {
19 21 const windowConf = `window.${configName}`;
20   - const outDir = 'dist';
21 22 // Ensure that the variable will not be modified
22 23 const configStr = `${windowConf}=${JSON.stringify(config)};
23   -
24 24 Object.freeze(${windowConf});
25 25 Object.defineProperty(window, "${configName}", {
26 26 configurable: false,
27 27 writable: false,
28 28 });
29   - `;
30   - fs.mkdirp(getCwdPath(outDir));
31   - writeFileSync(getCwdPath(`${outDir}/${configFileName}`), configStr);
  29 + `.replace(/\s/g, '');
  30 + fs.mkdirp(getCwdPath(OUTPUT_DIR));
  31 + writeFileSync(getCwdPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
32 32  
33   - console.log(chalk.cyan('✨ configuration file is build successfully:'));
34   - console.log(chalk.gray(outDir + '/' + chalk.green(configFileName)) + '\n');
  33 + console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
  34 + console.log(chalk.gray(OUTPUT_DIR + '/' + chalk.green(configFileName)) + '\n');
35 35 } catch (error) {
36 36 console.log(chalk.red('configuration file configuration file failed to package:\n' + error));
37 37 }
... ...
build/script/postBuild.ts
... ... @@ -4,6 +4,8 @@ import { argv } from 'yargs';
4 4 import { runBuildConfig } from './buildConf';
5 5 import chalk from 'chalk';
6 6  
  7 +import pkg from '../../package.json';
  8 +
7 9 export const runBuild = async () => {
8 10 try {
9 11 const argvList = argv._;
... ... @@ -12,7 +14,7 @@ export const runBuild = async () => {
12 14 if (!argvList.includes('no-conf')) {
13 15 await runBuildConfig();
14 16 }
15   - console.log(chalk.green.bold('✨ vite build successfully!\n'));
  17 + console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
16 18 } catch (error) {
17 19 console.log(chalk.red('vite build error:\n' + error));
18 20 process.exit(1);
... ...
build/typeing.d.ts 0 → 100644
  1 +declare module '*.json' {
  2 + const src: any;
  3 + export default src;
  4 +}
... ...
build/vite/plugin/html.ts
1 1 import type { Plugin } from 'vite';
  2 +import type { ViteEnv } from '../../utils';
2 3 import html from 'vite-plugin-html';
3   -import { ViteEnv } from '../../utils';
4 4  
5   -// @ts-ignore
6 5 import pkg from '../../../package.json';
7 6 import { GLOB_CONFIG_FILE_NAME } from '../../constant';
8 7  
... ...
build/vite/plugin/index.ts
... ... @@ -2,8 +2,6 @@ import type { Plugin } from 'vite';
2 2  
3 3 import PurgeIcons from 'vite-plugin-purge-icons';
4 4  
5   -// @ts-ignore
6   -import pkg from '../../../package.json';
7 5 import { ViteEnv } from '../../utils';
8 6 import { configHtmlPlugin } from './html';
9 7 import { configPwaConfig } from './pwa';
... ... @@ -16,13 +14,15 @@ import { configImageminPlugin } from './imagemin';
16 14  
17 15 // gen vite plugins
18 16 export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
  17 + const { VITE_USE_IMAGEMIN, VITE_USE_MOCK } = viteEnv;
  18 +
19 19 const vitePlugins: (Plugin | Plugin[])[] = [];
20 20  
21 21 // vite-plugin-html
22 22 vitePlugins.push(configHtmlPlugin(viteEnv, isBuild));
23 23  
24 24 // vite-plugin-mock
25   - vitePlugins.push(configMockPlugin(viteEnv, isBuild));
  25 + VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild));
26 26  
27 27 // vite-plugin-purge-icons
28 28 vitePlugins.push(PurgeIcons());
... ... @@ -38,7 +38,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
38 38  
39 39 if (isBuild) {
40 40 //vite-plugin-imagemin
41   - viteEnv.VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
  41 + VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
42 42  
43 43 // rollup-plugin-gzip
44 44 vitePlugins.push(configGzipPlugin(isBuild));
... ...
build/vite/plugin/mock.ts
1 1 import { viteMockServe } from 'vite-plugin-mock';
2   -import { ViteEnv } from '../../utils';
3 2  
4   -export function configMockPlugin(env: ViteEnv, isBuild: boolean) {
5   - const { VITE_USE_MOCK } = env;
6   -
7   - const useLocalMock = !isBuild && VITE_USE_MOCK;
8   - const useProdMock = isBuild && VITE_USE_MOCK;
9   -
10   - if (useLocalMock || useProdMock) {
11   - const mockPlugin = viteMockServe({
12   - ignore: /^\_/,
13   - mockPath: 'mock',
14   - showTime: true,
15   - localEnabled: useLocalMock,
16   - prodEnabled: useProdMock,
17   - injectCode: `
  3 +export function configMockPlugin(isBuild: boolean) {
  4 + return viteMockServe({
  5 + ignore: /^\_/,
  6 + mockPath: 'mock',
  7 + showTime: true,
  8 + localEnabled: !isBuild,
  9 + prodEnabled: isBuild,
  10 + injectCode: `
18 11 import { setupProdMockServer } from '../mock/_createProductionServer';
19 12  
20 13 setupProdMockServer();
21 14 `,
22   - });
23   - return mockPlugin;
24   - }
25   - return [];
  15 + });
26 16 }
... ...
package.json
... ... @@ -25,7 +25,7 @@
25 25 "ant-design-vue": "2.0.0",
26 26 "apexcharts": "^3.24.0",
27 27 "axios": "^0.21.1",
28   - "crypto-es": "^1.2.6",
  28 + "crypto-es": "^1.2.7",
29 29 "echarts": "^4.9.0",
30 30 "lodash-es": "^4.17.20",
31 31 "mockjs": "^1.1.0",
... ... @@ -46,7 +46,7 @@
46 46 "devDependencies": {
47 47 "@commitlint/cli": "^11.0.0",
48 48 "@commitlint/config-conventional": "^11.0.0",
49   - "@iconify/json": "^1.1.298",
  49 + "@iconify/json": "^1.1.299",
50 50 "@ls-lint/ls-lint": "^1.9.2",
51 51 "@purge-icons/generated": "^0.6.0",
52 52 "@types/echarts": "^4.9.3",
... ... @@ -95,12 +95,12 @@
95 95 "typescript": "^4.1.3",
96 96 "vite": "2.0.0-beta.65",
97 97 "vite-plugin-html": "^2.0.0",
98   - "vite-plugin-imagemin": "^0.2.4",
99   - "vite-plugin-mock": "^2.1.2",
  98 + "vite-plugin-imagemin": "^0.2.5",
  99 + "vite-plugin-mock": "^2.1.4",
100 100 "vite-plugin-purge-icons": "^0.6.0",
101 101 "vite-plugin-pwa": "^0.4.6",
102   - "vite-plugin-style-import": "^0.7.1",
103   - "vite-plugin-theme": "^0.4.1",
  102 + "vite-plugin-style-import": "^0.7.2",
  103 + "vite-plugin-theme": "^0.4.2",
104 104 "vue-eslint-parser": "^7.4.1",
105 105 "yargs": "^16.2.0"
106 106 },
... ...
vite.config.ts
... ... @@ -8,10 +8,9 @@ import { loadEnv } from 'vite';
8 8  
9 9 import { generateModifyVars } from './build/config/themeConfig';
10 10 import { createProxy } from './build/vite/proxy';
11   -
12 11 import { wrapperEnv } from './build/utils';
13   -
14 12 import { createVitePlugins } from './build/vite/plugin';
  13 +import { OUTPUT_DIR } from './build/constant';
15 14  
16 15 const pkg = require('./package.json');
17 16  
... ... @@ -19,7 +18,7 @@ function pathResolve(dir: string) {
19 18 return resolve(__dirname, '.', dir);
20 19 }
21 20  
22   -const root: string = process.cwd();
  21 +const root = process.cwd();
23 22  
24 23 export default ({ command, mode }: ConfigEnv): UserConfig => {
25 24 const env = loadEnv(mode, root);
... ... @@ -46,6 +45,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
46 45 },
47 46  
48 47 build: {
  48 + outDir: OUTPUT_DIR,
49 49 polyfillDynamicImport: VITE_LEGACY,
50 50 terserOptions: {
51 51 compress: {
... ...
yarn.lock
... ... @@ -1112,10 +1112,10 @@
1112 1112 dependencies:
1113 1113 cross-fetch "^3.0.6"
1114 1114  
1115   -"@iconify/json@^1.1.298":
1116   - version "1.1.298"
1117   - resolved "https://registry.npmjs.org/@iconify/json/-/json-1.1.298.tgz#32f4090d1b83e1a753e7cce7fe972efb856a72e1"
1118   - integrity sha512-h+IxOqYrW5zL4O+4zyaFl3kVnErHZEBE6d9ZCd6hK+oOAOx0uMkaUgesoR0Ci54U9igyY3Mp6vdMDzHLDCdzkg==
  1115 +"@iconify/json@^1.1.299":
  1116 + version "1.1.299"
  1117 + resolved "https://registry.npmjs.org/@iconify/json/-/json-1.1.299.tgz#e1aca556b83461316ba5ec04b232906b499a67a5"
  1118 + integrity sha512-oYHUgp5RZNE2CT3wKE/MWbmGK7lmubi30PD5l33HUU7yh4CznmzPL0Ewgg51Wn86NkFveZDcT+odMBTaayh9Ew==
1119 1119  
1120 1120 "@intlify/core-base@9.0.0-beta.16":
1121 1121 version "9.0.0-beta.16"
... ... @@ -3377,10 +3377,10 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2:
3377 3377 shebang-command "^2.0.0"
3378 3378 which "^2.0.1"
3379 3379  
3380   -crypto-es@^1.2.6:
3381   - version "1.2.6"
3382   - resolved "https://registry.npmjs.org/crypto-es/-/crypto-es-1.2.6.tgz#468f3573a5d7b82e3b63b0004f55f905a6d3b12c"
3383   - integrity sha512-PQnrovdr5ibmOxqAh/Vy+A30RokHom7kb9Z61EPwfASfbcJCrCG4+vNNegmebNVHiXvS7WjYpHDePxnE/biEbA==
  3380 +crypto-es@^1.2.7:
  3381 + version "1.2.7"
  3382 + resolved "https://registry.npmjs.org/crypto-es/-/crypto-es-1.2.7.tgz#754a6d52319a94fb4eb1f119297f17196b360f88"
  3383 + integrity sha512-UUqiVJ2gUuZFmbFsKmud3uuLcNP2+Opt+5ysmljycFCyhA0+T16XJmo1ev/t5kMChMqWh7IEvURNCqsg+SjZGQ==
3384 3384  
3385 3385 crypto-random-string@^2.0.0:
3386 3386 version "2.0.0"
... ... @@ -4919,11 +4919,16 @@ got@^8.3.1:
4919 4919 url-parse-lax "^3.0.0"
4920 4920 url-to-options "^1.0.1"
4921 4921  
4922   -graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2:
  4922 +graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0:
4923 4923 version "4.2.4"
4924 4924 resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
4925 4925 integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
4926 4926  
  4927 +graceful-fs@^4.2.2:
  4928 + version "4.2.5"
  4929 + resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.5.tgz#bc18864a6c9fc7b303f2e2abdb9155ad178fbe29"
  4930 + integrity sha512-kBBSQbz2K0Nyn+31j/w36fUfxkBW9/gfwRWdUY1ULReH3iokVJgddZAFcD1D0xlgTmFxJCbUkUclAlc6/IDJkw==
  4931 +
4927 4932 handlebars@^4.7.6:
4928 4933 version "4.7.6"
4929 4934 resolved "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
... ... @@ -9192,10 +9197,10 @@ vite-plugin-html@^2.0.0:
9192 9197 fs-extra "^9.1.0"
9193 9198 html-minifier-terser "^5.1.1"
9194 9199  
9195   -vite-plugin-imagemin@^0.2.4:
9196   - version "0.2.4"
9197   - resolved "https://registry.npmjs.org/vite-plugin-imagemin/-/vite-plugin-imagemin-0.2.4.tgz#c44f7a39d84b8a0af8468b90505a147fd5297b67"
9198   - integrity sha512-7VQwm2mip/JNp0oTqVOLZ+eo7ijZT5wP3AZF3PwJErZ48iT02PcDbC1Ij00Q2zoFPbtMkAuEbcLh1vK5C1m+pQ==
  9200 +vite-plugin-imagemin@^0.2.5:
  9201 + version "0.2.5"
  9202 + resolved "https://registry.npmjs.org/vite-plugin-imagemin/-/vite-plugin-imagemin-0.2.5.tgz#926b57f570f55d29081ebbea5c073298e411ef42"
  9203 + integrity sha512-wweK2QLJTNIkqEoCXuKJJP1Y+Duu2tA0CKtST6ovzXra4kMx6BQ3nWCRkr66Ye6fQii5yPSuE1ZtTNVLSi9mmw==
9199 9204 dependencies:
9200 9205 "@types/imagemin" "^7.0.0"
9201 9206 "@types/imagemin-gifsicle" "^7.0.0"
... ... @@ -9205,6 +9210,7 @@ vite-plugin-imagemin@^0.2.4:
9205 9210 "@types/imagemin-svgo" "^8.0.0"
9206 9211 "@types/imagemin-webp" "^5.1.1"
9207 9212 chalk "^4.1.0"
  9213 + debug "^4.3.1"
9208 9214 fs-extra "^9.1.0"
9209 9215 imagemin "^7.0.1"
9210 9216 imagemin-gifsicle "^7.0.0"
... ... @@ -9214,10 +9220,10 @@ vite-plugin-imagemin@^0.2.4:
9214 9220 imagemin-svgo "^8.0.0"
9215 9221 imagemin-webp "^6.0.0"
9216 9222  
9217   -vite-plugin-mock@^2.1.2:
9218   - version "2.1.2"
9219   - resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-2.1.2.tgz#a66d65947d565862395a0a181cb210b0076db9cc"
9220   - integrity sha512-b/YoQyBQhuyXOm/30bfVOKKBD7N50nw/5xTyyIXOTsry8LOPa5AZR9/2s2zPTioMeb63Ey4vga6CG8E2Tj8XVg==
  9223 +vite-plugin-mock@^2.1.4:
  9224 + version "2.1.4"
  9225 + resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-2.1.4.tgz#b1f91418e7ed4678c969d5581276fe68c27a27d0"
  9226 + integrity sha512-3qYMDZ7jmTVk7mxPpKEgnbA6B19NKvkuEzpZrKq3I9yJH1tjsTIQi/t3EaH2rXJip4EZff6NRJO8aarW3OAsOg==
9221 9227 dependencies:
9222 9228 "@rollup/plugin-node-resolve" "^11.1.1"
9223 9229 "@types/mockjs" "^1.0.3"
... ... @@ -9251,23 +9257,26 @@ vite-plugin-pwa@^0.4.6:
9251 9257 pretty-bytes "^5.5.0"
9252 9258 workbox-build "^6.1.0"
9253 9259  
9254   -vite-plugin-style-import@^0.7.1:
9255   - version "0.7.1"
9256   - resolved "https://registry.npmjs.org/vite-plugin-style-import/-/vite-plugin-style-import-0.7.1.tgz#f55949f6821937a7027c4afa8f6ce4c0b6ef9609"
9257   - integrity sha512-Nr2PH8i8i9GIQhQRkipwYTYKur+/1mkCrMi4sXbMLcoUsz7wq7uZ1c3XcXA8B0Au3lZm+AKN3KiUrDD4Evx9EQ==
  9260 +vite-plugin-style-import@^0.7.2:
  9261 + version "0.7.3"
  9262 + resolved "https://registry.npmjs.org/vite-plugin-style-import/-/vite-plugin-style-import-0.7.3.tgz#4a9fb08bf5f2fc4796391c9be9a587ecb5c97e9e"
  9263 + integrity sha512-oKM6vOl7iWaB5U1HcR5oM1oPRhT1n5yJt7h4h9jwpMPCD5ckHPcSjjSU7ZlOJkoS/IWEnDkQqoZi162bOs1rTQ==
9258 9264 dependencies:
9259 9265 "@rollup/pluginutils" "^4.1.0"
9260 9266 change-case "^4.1.2"
  9267 + debug "^4.3.1"
9261 9268 es-module-lexer "^0.3.26"
9262 9269 magic-string "^0.25.7"
9263 9270  
9264   -vite-plugin-theme@^0.4.1:
9265   - version "0.4.1"
9266   - resolved "https://registry.npmjs.org/vite-plugin-theme/-/vite-plugin-theme-0.4.1.tgz#02157947d1954ef59e3747e1b4f7d002b6b3f7cd"
9267   - integrity sha512-ap0NpgBAKOdKQD1zW5P56sYPTJc6DO9FtXsrnOjXtxQ2gb2qKuRAnVV5+UFuO/Mgjh2QyuN9AnT5ANwGTjl0og==
  9271 +vite-plugin-theme@^0.4.2:
  9272 + version "0.4.2"
  9273 + resolved "https://registry.npmjs.org/vite-plugin-theme/-/vite-plugin-theme-0.4.2.tgz#bb4791ddd88205f2fd07ae9aff7a92d5d427b516"
  9274 + integrity sha512-NOk56zCYloaVmqWh8o+OShJLVTNVsDZRLEeToHsv0yGXd94gCiYTflguGtcmsSQjQfQYOz/gGKjLAU4KPH/FKA==
9268 9275 dependencies:
9269 9276 "@types/tinycolor2" "^1.4.2"
  9277 + chalk "^4.1.0"
9270 9278 clean-css "^4.2.3"
  9279 + debug "^4.3.1"
9271 9280 es-module-lexer "^0.3.26"
9272 9281 tinycolor2 "^1.4.2"
9273 9282  
... ...