Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Dec 1, 2020
1 parent 5db3ce7 commit 6f8d753
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 152 deletions.
1 change: 1 addition & 0 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface ViteEnv {
VITE_USE_CDN: boolean;
VITE_DROP_CONSOLE: boolean;
VITE_BUILD_GZIP: boolean;
VITE_DYNAMIC_IMPORT: boolean;
}

// Read all environment variable configuration files to process.env
Expand Down
5 changes: 2 additions & 3 deletions build/vite/plugin/transform/dynamic-import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getPath(path: string) {
return path.replace('src/views', '');
}

const dynamicImportTransform = function (env: any = {}): Transform {
const dynamicImportTransform = function (enableDynamicImport: boolean): Transform {
return {
test({ path }) {
// Only convert the file
Expand All @@ -22,8 +22,7 @@ const dynamicImportTransform = function (env: any = {}): Transform {
);
},
transform({ code }) {
const { VITE_DYNAMIC_IMPORT } = env;
if (!VITE_DYNAMIC_IMPORT) {
if (!enableDynamicImport) {
return code;
}

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
justify-content: center;
align-items: center;
flex-direction: column;
background: #f0f2f5;
}

.app-loading .app-loading-wrap {
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"path-to-regexp": "^6.2.0",
"qrcode": "^1.4.4",
"sortablejs": "^1.12.0",
"vditor": "^3.6.6",
"vditor": "^3.7.0",
"vue": "^3.0.3",
"vue-i18n": "^9.0.0-beta.8",
"vue-router": "^4.0.0-rc.5",
"vue-router": "^4.0.0-rc.6",
"vue-types": "^3.0.1",
"vuex": "^4.0.0-rc.2",
"vuex-module-decorators": "^1.0.1",
Expand All @@ -47,7 +47,7 @@
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@iconify/json": "^1.1.264",
"@iconify/json": "^1.1.266",
"@ls-lint/ls-lint": "^1.9.2",
"@purge-icons/generated": "^0.4.1",
"@types/echarts": "^4.9.2",
Expand All @@ -62,8 +62,8 @@
"@types/sortablejs": "^1.10.6",
"@types/yargs": "^15.0.10",
"@types/zxcvbn": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"@vue/compiler-sfc": "^3.0.3",
"@vuedx/typecheck": "^0.2.4-0",
"@vuedx/typescript-plugin-vue": "^0.2.4-0",
Expand All @@ -87,7 +87,7 @@
"lint-staged": "^10.5.2",
"portfinder": "^1.0.28",
"postcss-import": "^12.0.1",
"prettier": "^2.2.0",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"rollup-plugin-visualizer": "^4.1.2",
"stylelint": "^13.8.0",
Expand All @@ -101,7 +101,7 @@
"vite-plugin-html": "^1.0.0-beta.2",
"vite-plugin-mock": "^1.0.6",
"vite-plugin-purge-icons": "^0.4.5",
"vite-plugin-pwa": "^0.1.5",
"vite-plugin-pwa": "^0.1.7",
"vue-eslint-parser": "^7.1.1",
"yargs": "^16.1.0"
},
Expand Down
7 changes: 6 additions & 1 deletion src/router/menus/modules/demo/comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const menu: MenuModule = {
menu: {
name: 'routes.demo.comp.comp',
path: '/comp',

tag: {
dot: true,
},
children: [
{
path: 'basic',
Expand Down Expand Up @@ -47,6 +49,9 @@ const menu: MenuModule = {
{
path: 'loading',
name: 'routes.demo.comp.loading',
tag: {
content: 'new',
},
},
{
path: 'scroll',
Expand Down
101 changes: 21 additions & 80 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { UserConfig } from 'vite';

import type { UserConfig, Resolver } from 'vite';
import { resolve } from 'path';

import { modifyVars } from './build/config/lessModifyVars';
Expand All @@ -16,94 +15,41 @@ const pkg = require('./package.json');

const viteEnv = loadEnv();

const {
VITE_PORT,
VITE_PUBLIC_PATH,
VITE_PROXY,
VITE_DROP_CONSOLE,
// VITE_USE_CDN,
} = viteEnv;
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE, VITE_DYNAMIC_IMPORT } = viteEnv;

function pathResolve(dir: string) {
return resolve(__dirname, '.', dir);
}

const alias: Record<string, string> = {
'/@/': pathResolve('src'),
};

const root: string = process.cwd();

const resolvers: Resolver[] = [];

const viteConfig: UserConfig = {
/**
* Entry. Use this to specify a js entry file in setting cases where an
* `index.html` does not exist (e.g. serving vite assets from a different host)
* @default 'index.html'
*/
// TODO build error
// entry: 'public/index.html',
root,
alias,
/**
* port
* @default '3000'
*/
port: VITE_PORT,
/**
* @default 'localhost'
*/
hostname: 'localhost',
/**
* Run to open the browser automatically
* @default 'false'
*/
open: false,
/**
* Set to `false` to disable minification, or specify the minifier to setting.
* Available options are 'terser' or 'esbuild'.
* @default 'terser'
*/
minify: 'terser',

/**
* Base public path when served in production.
* @default '/'
*/
base: VITE_PUBLIC_PATH,

/**
* Directory relative from `root` where build output will be placed. If the
* directory exists, it will be removed before the build.
* @default 'dist'
*/
outDir: 'dist',
/**
* Whether to generate sourcemap
* @default false
*/
sourcemap: false,
/**
* Directory relative from `outDir` where the built js/css/image assets will
* be placed.
* @default '_assets'
*/
assetsDir: '_assets',
/**
* Static asset files smaller than this number (in bytes) will be inlined as
* base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
* @default 4096
*/
assetsInlineLimit: 4096,
/**
* Transpile target for esbuild.
* @default 'es2020'
*/
esbuildTarget: 'es2019',
/**
* Whether to log asset info to console
* @default false
*/
silent: false,
/**
* Import alias. The entries can either be exact request -> request mappings
* (exact, no wildcard syntax), or request path -> fs directory mappings.
* When using directory mappings, the key **must start and end with a slash**.
* ```
*/
alias: {
'/@/': pathResolve('src'),
},

// terser options
terserOptions: {
compress: {
Expand Down Expand Up @@ -134,25 +80,20 @@ const viteConfig: UserConfig = {
],
},

// Local cross-domain proxy
proxy: createProxy(VITE_PROXY),
plugins: createVitePlugins(viteEnv),
rollupInputOptions: {
// TODO
// external: VITE_USE_CDN ? externals : [],
plugins: createRollupPlugin(),
},
};

export default {
...viteConfig,
transforms: [
globbyTransform({
resolvers: viteConfig.resolvers,
root: viteConfig.root,
alias: viteConfig.alias,
resolvers: resolvers,
root: root,
alias: alias,
includes: [resolve('src/router'), resolve('src/locales')],
}),
dynamicImportTransform(viteEnv),
dynamicImportTransform(VITE_DYNAMIC_IMPORT),
],
} as UserConfig;
};

export default viteConfig;
Loading

0 comments on commit 6f8d753

Please sign in to comment.