-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'template' into release
- Loading branch information
Showing
42 changed files
with
630 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env ts-node | ||
import autoImport from '../plugins/autoImport.js'; | ||
autoImport().buildStart(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; | ||
import Components from 'unplugin-vue-components/vite'; | ||
import { resolver } from './autoImport'; | ||
export default () => | ||
Components({ | ||
// 组件自动注册(包括components下的所有.vue组件和ElementPlus组件) | ||
include: [], | ||
dts: false, | ||
resolvers: [ElementPlusResolver({ importStyle: false }), resolver([3], [2])], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { dirname, resolve } from 'path'; | ||
import * as fs from 'fs'; | ||
import { createPlugin } from 'vite-plugin-autogeneration-import-file'; | ||
import { fileURLToPath } from 'url'; | ||
const { autoImport, resolver: resolverFn } = createPlugin(); | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
function pathResolve(dir: string) { | ||
return resolve(__dirname, '../', dir); | ||
} | ||
export default () => | ||
autoImport([ | ||
// 自动生成 | ||
{ | ||
// svg icon type | ||
pattern: ['*.svg'], | ||
dir: pathResolve('src/icons/svg'), | ||
toFile: pathResolve('types/meIconComments.d.ts'), | ||
name: 'MeIcon_{{name}}', | ||
template: fs.readFileSync(pathResolve('./template/meIconComments.d.ts'), 'utf-8'), | ||
codeTemplates: [{ key: '//code', template: '{{name}}: Icon;\n ' }], | ||
}, | ||
{ | ||
// pinia module | ||
pattern: ['**/*.{ts,js}', '*.{ts,js}'], | ||
dir: pathResolve('src/store/modules'), | ||
toFile: pathResolve('src/store/module.ts'), | ||
name: 'use_{{name}}_store', | ||
}, | ||
{ | ||
// auto import directives | ||
pattern: ['*.ts', '**/index.ts'], | ||
dir: pathResolve('src/directives'), | ||
toFile: pathResolve('types/directives.d.ts'), | ||
template: fs.readFileSync(pathResolve('./template/directives.d.ts'), 'utf-8'), | ||
codeTemplates: [ | ||
{ | ||
key: '//code', | ||
template: '{{name}}: typeof import("{{path}}")["default"];\n ', | ||
}, | ||
], | ||
name: 'V_{{name}}', | ||
}, | ||
{ | ||
// auto import components | ||
pattern: ['*.{vue,ts}', '**/index.{vue,ts}'], | ||
dir: pathResolve('src/components'), | ||
toFile: pathResolve('types/components.d.ts'), | ||
template: fs.readFileSync(pathResolve('./template/components.d.ts'), 'utf-8'), | ||
codeTemplates: [ | ||
{ | ||
key: '//code', | ||
template: '{{name}}: typeof import("{{path}}")["default"];\n ', | ||
}, | ||
{ | ||
key: '//typeCode', | ||
template: 'type {{name}}Instance = InstanceType<typeof import("{{path}}")["default"]>;\n ', | ||
}, | ||
], | ||
name: '_{{name}}', | ||
}, | ||
]); | ||
|
||
export const resolver = resolverFn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import AutoImport from 'unplugin-auto-import/vite'; | ||
import { resolve } from 'path'; | ||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; | ||
function pathResolve(dir: string) { | ||
return resolve(__dirname, '../', dir); | ||
} | ||
export default () => | ||
AutoImport({ | ||
// 自动加载API | ||
imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'], | ||
// 可以选择auto-imports.d.ts生成的位置,使用ts建议设置为'src/auto-imports.d.ts' | ||
dts: pathResolve('types/auto-imports.d.ts'), | ||
resolvers: [ElementPlusResolver()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { babel } from '@rollup/plugin-babel'; | ||
import { createRequire } from 'node:module'; | ||
export default () => | ||
babel({ | ||
babelrc: false, | ||
extensions: ['.ts', '.tsx'], | ||
plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]], | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: ['chrome 87', 'safari 13', 'firefox 78', 'edge 88'], | ||
useBuiltIns: 'usage', | ||
bugfixes: true, | ||
loose: false, | ||
modules: false, | ||
corejs: createRequire(import.meta.url)('core-js/package.json').version, | ||
shippedProposals: true, | ||
ignoreBrowserslistConfig: true, | ||
}, | ||
], | ||
], | ||
exclude: 'node_modules/**', | ||
babelHelpers: 'runtime', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ConfigEnv } from 'vite'; | ||
import autoComponents from './autoComponents'; | ||
import autoImport from './autoImport'; | ||
import autoImportApi from './autoImportApi'; | ||
import babel from './babel'; | ||
import mock from './mock'; | ||
import svgLoader from './svgLoader'; | ||
import vueSetUpExtend from './vueSetUpExtend'; | ||
import { visualizer } from 'rollup-plugin-visualizer'; //打包大小分析(stats.html) | ||
import vue from '@vitejs/plugin-vue'; | ||
// import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; | ||
import { splitVendorChunkPlugin } from 'vite'; | ||
import viteCompression from 'vite-plugin-compression'; //打包压缩 | ||
|
||
export default (configEnv: ConfigEnv) => { | ||
return [ | ||
vue(), | ||
splitVendorChunkPlugin(), //打包分析,会生成stats.html展示打包情况 | ||
// VueI18nPlugin({ | ||
// /* options */ | ||
// // locale messages resource pre-compile option | ||
// include: ['./src/**/lang/**/*.json', './src/**/lang/*.json'], | ||
// }), | ||
visualizer(), | ||
viteCompression(), | ||
autoComponents(), | ||
autoImport(), | ||
autoImportApi(), | ||
babel(), | ||
mock(configEnv), | ||
svgLoader(), | ||
vueSetUpExtend(), | ||
]; | ||
}; |
Oops, something went wrong.