-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
2,408 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import react from '@vitejs/plugin-react'; | ||
import type { ConfigEnv, PluginOption } from 'vite'; | ||
|
||
// svg配置 | ||
import { configSvgPlugin } from './svg'; | ||
|
||
export function createVitePlugins(_isBuild = false, _configEnv: ConfigEnv) { | ||
const vitePlugins: PluginOption[] = []; | ||
|
||
vitePlugins.push(react()); | ||
|
||
vitePlugins.push(configSvgPlugin()); | ||
|
||
return vitePlugins; | ||
} |
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,18 @@ | ||
/** | ||
* svg | ||
* https://github.com/anncwb/vite-plugin-svg-icons/blob/main/README.zh_CN.md | ||
*/ | ||
import path from 'path'; | ||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; | ||
|
||
export function configSvgPlugin() { | ||
const svgPlugin = createSvgIconsPlugin({ | ||
// 指定需要缓存的图标文件夹 | ||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], | ||
// 压缩配置 | ||
// svgoOptions: false, | ||
// 指定symbolId格式 | ||
symbolId: 'icon-[dir]-[name]', | ||
}); | ||
return svgPlugin; | ||
} |
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,20 @@ | ||
import path from 'path'; | ||
import type { ResolveOptions, AliasOptions } from 'vite'; | ||
|
||
type myResolveOptions = ResolveOptions & { alias?: AliasOptions }; | ||
|
||
export function createViteResolve(myDirname: string): myResolveOptions { | ||
const viteResolve: myResolveOptions = { | ||
// 引用别名配置 | ||
alias: { | ||
// 配置@别名 | ||
'@': `${path.resolve(myDirname, 'src')}`, | ||
// 配置#别名 | ||
'#': `${path.resolve(myDirname, 'types')}`, | ||
}, | ||
// 导入时想要省略的扩展名列表。注意,不 建议忽略自定义导入类型的扩展名(例如:.vue),因为它会干扰 IDE 和类型支持。 | ||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'], | ||
}; | ||
|
||
return viteResolve; | ||
} |
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
Oops, something went wrong.