chore: update deps

This commit is contained in:
vben
2020-12-01 21:02:37 +08:00
parent 5db3ce7737
commit 6f8d753ae0
7 changed files with 99 additions and 152 deletions

View File

@@ -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';
@@ -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: {
@@ -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;