mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-30 09:24:46 +08:00
feat: 根治非必要的vue-router
动态路由警告No match found for location with path
This commit is contained in:
parent
1065ed4b78
commit
b9e6556409
@ -6,6 +6,7 @@ import svgLoader from "vite-svg-loader";
|
|||||||
import type { PluginOption } from "vite";
|
import type { PluginOption } from "vite";
|
||||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
import { configCompressPlugin } from "./compress";
|
import { configCompressPlugin } from "./compress";
|
||||||
|
import removeNoMatch from "vite-plugin-router-warn";
|
||||||
import { visualizer } from "rollup-plugin-visualizer";
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
import removeConsole from "vite-plugin-remove-console";
|
import removeConsole from "vite-plugin-remove-console";
|
||||||
import { themePreprocessorPlugin } from "@pureadmin/theme";
|
import { themePreprocessorPlugin } from "@pureadmin/theme";
|
||||||
@ -20,18 +21,27 @@ export function getPluginsList(
|
|||||||
const lifecycle = process.env.npm_lifecycle_event;
|
const lifecycle = process.env.npm_lifecycle_event;
|
||||||
return [
|
return [
|
||||||
vue(),
|
vue(),
|
||||||
|
// jsx、tsx语法支持
|
||||||
|
vueJsx(),
|
||||||
VueI18nPlugin({
|
VueI18nPlugin({
|
||||||
runtimeOnly: true,
|
runtimeOnly: true,
|
||||||
compositionOnly: true,
|
compositionOnly: true,
|
||||||
include: [resolve("locales/**")]
|
include: [resolve("locales/**")]
|
||||||
}),
|
}),
|
||||||
// jsx、tsx语法支持
|
|
||||||
vueJsx(),
|
|
||||||
VITE_CDN ? cdn : null,
|
|
||||||
configCompressPlugin(VITE_COMPRESSION),
|
|
||||||
// 线上环境删除console
|
|
||||||
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
|
||||||
viteBuildInfo(),
|
viteBuildInfo(),
|
||||||
|
/**
|
||||||
|
* 开发环境下移除非必要的vue-router动态路由警告No match found for location with path
|
||||||
|
* 非必要具体看 https://github.com/vuejs/router/issues/521 和 https://github.com/vuejs/router/issues/359
|
||||||
|
* vite-plugin-router-warn只在开发环境下启用,只处理vue-router文件并且只在服务启动或重启时运行一次,性能消耗可忽略不计
|
||||||
|
*/
|
||||||
|
removeNoMatch(),
|
||||||
|
// mock支持
|
||||||
|
vitePluginFakeServer({
|
||||||
|
logger: false,
|
||||||
|
include: "mock",
|
||||||
|
infixName: false,
|
||||||
|
enableProd: true
|
||||||
|
}),
|
||||||
// 自定义主题
|
// 自定义主题
|
||||||
themePreprocessorPlugin({
|
themePreprocessorPlugin({
|
||||||
scss: {
|
scss: {
|
||||||
@ -41,13 +51,10 @@ export function getPluginsList(
|
|||||||
}),
|
}),
|
||||||
// svg组件化支持
|
// svg组件化支持
|
||||||
svgLoader(),
|
svgLoader(),
|
||||||
// mock支持
|
VITE_CDN ? cdn : null,
|
||||||
vitePluginFakeServer({
|
configCompressPlugin(VITE_COMPRESSION),
|
||||||
logger: false,
|
// 线上环境删除console
|
||||||
include: "mock",
|
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
||||||
infixName: false,
|
|
||||||
enableProd: true
|
|
||||||
}),
|
|
||||||
// 打包分析
|
// 打包分析
|
||||||
lifecycle === "report"
|
lifecycle === "report"
|
||||||
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
||||||
|
@ -157,6 +157,7 @@
|
|||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-fake-server": "^2.0.0",
|
"vite-plugin-fake-server": "^2.0.0",
|
||||||
"vite-plugin-remove-console": "^2.1.1",
|
"vite-plugin-remove-console": "^2.1.1",
|
||||||
|
"vite-plugin-router-warn": "^1.0.0",
|
||||||
"vite-svg-loader": "^4.0.0",
|
"vite-svg-loader": "^4.0.0",
|
||||||
"vue-eslint-parser": "^9.3.2",
|
"vue-eslint-parser": "^9.3.2",
|
||||||
"vue-tsc": "^1.8.22"
|
"vue-tsc": "^1.8.22"
|
||||||
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -328,6 +328,9 @@ devDependencies:
|
|||||||
vite-plugin-remove-console:
|
vite-plugin-remove-console:
|
||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
|
vite-plugin-router-warn:
|
||||||
|
specifier: ^1.0.0
|
||||||
|
version: registry.npmjs.org/vite-plugin-router-warn@1.0.0
|
||||||
vite-svg-loader:
|
vite-svg-loader:
|
||||||
specifier: ^4.0.0
|
specifier: ^4.0.0
|
||||||
version: 4.0.0
|
version: 4.0.0
|
||||||
@ -9305,3 +9308,9 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.3.0
|
tslib: 2.3.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
registry.npmjs.org/vite-plugin-router-warn@1.0.0:
|
||||||
|
resolution: {integrity: sha512-jnr7faHJPkKxukBXVpg7Ui1UDqhmxD7xU6JGidq8ivSHTsNAPqzSpPpwW8O1PBP/0+Owq4bLfNNk11drOkz4xA==, registry: https://registry.npmmirror.com/, tarball: https://registry.npmjs.org/vite-plugin-router-warn/-/vite-plugin-router-warn-1.0.0.tgz}
|
||||||
|
name: vite-plugin-router-warn
|
||||||
|
version: 1.0.0
|
||||||
|
dev: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user