1404/11/04- first
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import type { UserConfigExport } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import { resolve } from 'path'
|
||||
import UnoCSS from './vitePlugins/unoCss'
|
||||
import Components from './vitePlugins/unplugin-vue-components'
|
||||
import AutoImport from './vitePlugins/unplugin-auto-import'
|
||||
import VitePWA from './vitePlugins/vite-plugin-pwa'
|
||||
/**
|
||||
* @see https://vitejs.dev/config/
|
||||
*/
|
||||
export const baseConfigVite: UserConfigExport = {
|
||||
// Directory to serve as plain static assets.
|
||||
publicDir: 'public',
|
||||
// Adjust console output verbosity.
|
||||
//logLevel: 'info',
|
||||
//VitePWA
|
||||
plugins: [vue(), vueJsx(), UnoCSS, AutoImport, Components],
|
||||
resolve: {
|
||||
extensions: ['*', '.js', '.vue', '.json', '.ts', '.tsx', '.mjs'],
|
||||
alias: {
|
||||
'@root': fileURLToPath(new URL('../../../', import.meta.url)),
|
||||
'@core': fileURLToPath(new URL('../', import.meta.url)),
|
||||
'@assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
|
||||
'@': fileURLToPath(new URL('../../', import.meta.url)),
|
||||
'~': fileURLToPath(new URL('./node_modules', import.meta.url))
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
host: true
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
modifyVars: {
|
||||
// Used for global import to avoid the need to import each style file separately
|
||||
// reference: Avoid repeated references
|
||||
hack: `; @import (reference) "${resolve('./src/core/assets/css/var.less')}"`
|
||||
},
|
||||
javascriptEnabled: true
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* By default, Vite will crawl your index.html to detect dependencies that
|
||||
* need to be pre-bundled. If build.rollupOptions.input is specified,
|
||||
* Vite will crawl those entry points instead.
|
||||
*
|
||||
* @see https://vitejs.dev/config/#optimizedeps-entries
|
||||
*/
|
||||
optimizeDeps: {
|
||||
//include: ['vue'],
|
||||
//disabled: false
|
||||
},
|
||||
build: {
|
||||
//minify: 'terser',
|
||||
// Do not warn about large chunks
|
||||
// chunkSizeWarningLimit: Infinity,
|
||||
// Double the default size threshold for inlined assets
|
||||
// https://vitejs.dev/config/build-options.html#build-assetsinlinelimit
|
||||
//assetsInlineLimit: 4096 * 2,
|
||||
//commonjsOptions: { include: [] }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import UnoCSS from 'unocss/vite'
|
||||
import { presetAttributify, presetUno } from 'unocss'
|
||||
import transformerDirectives from '@unocss/transformer-directives'
|
||||
import transformerVariantGroup from '@unocss/transformer-variant-group'
|
||||
import transformerCompileClass from '@unocss/transformer-compile-class'
|
||||
//import { presetScrollbarHide } from 'unocss-preset-scrollbar-hide'
|
||||
|
||||
/**
|
||||
* @see https://github.com/unocss/unocss
|
||||
*/
|
||||
export default UnoCSS({
|
||||
presets: [
|
||||
/**
|
||||
* @see https://github.com/unocss/unocss/tree/main/packages/preset-attributify
|
||||
*/
|
||||
presetAttributify({
|
||||
/* preset options */
|
||||
}),
|
||||
/**
|
||||
* @see https://github.com/unocss/unocss/tree/main/packages/preset-uno
|
||||
*/
|
||||
presetUno()
|
||||
/**
|
||||
* @see https://github.com/reslear/unocss-preset-scrollbar-hide
|
||||
*/
|
||||
//presetScrollbarHide()
|
||||
// ...custom presets
|
||||
],
|
||||
transformers: [
|
||||
/**
|
||||
* @see https://github.com/unocss/unocss/tree/main/packages/transformer-directives
|
||||
*/
|
||||
transformerDirectives(),
|
||||
/**
|
||||
* @see https://github.com/unocss/unocss/tree/main/packages/transformer-variant-group
|
||||
*/
|
||||
transformerVariantGroup(),
|
||||
/**
|
||||
* @see https://github.com/unocss/unocss/tree/main/packages/transformer-compile-class/
|
||||
*/
|
||||
transformerCompileClass()
|
||||
]
|
||||
})
|
||||
@@ -0,0 +1,85 @@
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
|
||||
/**
|
||||
* @see https://github.com/antfu/unplugin-auto-import
|
||||
*/
|
||||
export default AutoImport({
|
||||
// targets to transform
|
||||
include: [
|
||||
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
|
||||
/\.vue$/,
|
||||
/\.vue\?vue/, // .vue
|
||||
/\.md$/ // .md
|
||||
],
|
||||
|
||||
// global imports to register
|
||||
imports: [
|
||||
// presets
|
||||
'vue',
|
||||
'vue-router',
|
||||
'pinia',
|
||||
// custom
|
||||
{
|
||||
/*'@vueuse/core': [
|
||||
// named imports
|
||||
'useMouse', // import { useMouse } from '@vueuse/core',
|
||||
// alias
|
||||
['useFetch', 'useMyFetch'] // import { useFetch as useMyFetch } from '@vueuse/core',
|
||||
]*/
|
||||
/* axios: [
|
||||
// default imports
|
||||
['default', 'axios'] // import { default as axios } from 'axios',
|
||||
],*/
|
||||
/*'[package-name]': [
|
||||
'[import-names]',
|
||||
// alias
|
||||
['[from]', '[alias]']
|
||||
]*/
|
||||
}
|
||||
// example type import
|
||||
/*{
|
||||
from: 'vue-router',
|
||||
imports: ['RouteLocationRaw'],
|
||||
type: true
|
||||
}*/
|
||||
],
|
||||
// Enable auto import by filename for default module exports under directories
|
||||
defaultExportByFilename: false,
|
||||
|
||||
// Auto import for module exports under directories
|
||||
// by default it only scan one level of modules under the directory
|
||||
dirs: [
|
||||
// './hooks',
|
||||
// './composables' // only root modules
|
||||
// './composables/**', // all nested modules
|
||||
// ...
|
||||
],
|
||||
|
||||
// Filepath to generate corresponding .d.ts file.
|
||||
// Defaults to './auto-imports.d.ts' when `typescript` is installed locally.
|
||||
// Set `false` to disable.
|
||||
dts: './auto-imports.d.ts',
|
||||
|
||||
// Cache the result of resolving, across multiple vite builds.
|
||||
// A custom path is supported.
|
||||
// When set to `true`, the cache will be stored in `node_modules/.cache/unplugin-auto-import.json`.
|
||||
cache: false,
|
||||
|
||||
// Auto import inside Vue template
|
||||
// see https://github.com/unjs/unimport/pull/15 and https://github.com/unjs/unimport/pull/72
|
||||
vueTemplate: false,
|
||||
|
||||
// Custom resolvers, compatible with `unplugin-vue-components`
|
||||
// see https://github.com/antfu/unplugin-auto-import/pull/23/
|
||||
resolvers: [
|
||||
/* ... */
|
||||
],
|
||||
|
||||
// Generate corresponding .eslintrc-auto-import.json file.
|
||||
// eslint globals Docs - https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals
|
||||
eslintrc: {
|
||||
enabled: true, // Default `false`
|
||||
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
|
||||
globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,38 @@
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
||||
|
||||
/**
|
||||
* @see https://github.com/antfu/unplugin-vue-components
|
||||
*/
|
||||
export default Components({
|
||||
// valid file extensions for components.
|
||||
//extensions: ['vue', 'ts'],
|
||||
// Allow subdirectories as namespace prefix for components.
|
||||
// directoryAsNamespace: false,
|
||||
//collapseSamePrefixes: false,
|
||||
//allowOverrides: true,
|
||||
dts: true,
|
||||
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
||||
//include: [/\/index\.vue$/, /\/index\.ts$/, /\.vue\?vue/, /\.md$/],
|
||||
//'src/components/**'
|
||||
globs: [
|
||||
'src/components/*/index.ts',
|
||||
'src/components/*/_index.vue',
|
||||
'src/components/*',
|
||||
'src/core/components/*/index.ts',
|
||||
'src/core/components/*/_index.vue',
|
||||
'src/core/components/*'
|
||||
],
|
||||
//deep: true,s
|
||||
resolvers: [AntDesignVueResolver({ importStyle: false })]
|
||||
})
|
||||
|
||||
/***
|
||||
* dirs: ['src/hooks/**', 'src/utils/**', 'src/store/**', 'src/api/**'],
|
||||
* Components({
|
||||
* dirs: ['src/components', 'src/icons'],
|
||||
* extensions: ['vue'],
|
||||
* deep: true,
|
||||
* dts: './typings/components.d.ts'
|
||||
* }),
|
||||
*/
|
||||
@@ -0,0 +1,33 @@
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
|
||||
//todo complete
|
||||
export default VitePWA({
|
||||
base: '/',
|
||||
includeAssets: ['favicon.svg', 'favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
|
||||
manifest: {
|
||||
name: 'Admin V3 - A complete Vue 3 design system',
|
||||
short_name: 'AdminV3',
|
||||
start_url: '/',
|
||||
display: 'standalone',
|
||||
theme_color: '#ffffff',
|
||||
background_color: '#ffffff',
|
||||
icons: [
|
||||
{
|
||||
src: 'pwa-192x192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'pwa-512x512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'pwa-512x512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'any maskable'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user