Skip to content

Commit

Permalink
Update vuetify 3.3.1.
Browse files Browse the repository at this point in the history
Changed Treeshaking algorithm. (Fix for #14).
Fixed Navigation block problem (#16).
  • Loading branch information
logue committed May 24, 2023
1 parent 44f6ad3 commit bc0cbea
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 283 deletions.
3 changes: 3 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ declare module 'vuetify' {
import vuetify from 'vuetify/dist/vuetify.d.ts';
return vuetify;
}
// if use color
// declare module 'vuetify/lib/util/colors.mjs';

interface ImportMetaEnv {
// see https://vitejs.dev/guide/env-and-mode.html#env-files
// add .env variables.
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/package.json",
"name": "vite-vuetify-ts-starter",
"description": "Vue3 Vuetify TypeScript Startar project for Vite.",
"version": "1.5.1",
"version": "1.5.2",
"license": "MIT",
"type": "module",
"private": true,
Expand Down Expand Up @@ -46,17 +46,17 @@
"pinia-plugin-persistedstate": "^3.1.0",
"vue": "^3.3.4",
"vue-router": "^4.2.1",
"vuetify": "^3.3.0",
"vuetify": "^3.3.1",
"webfontloader": "^1.6.28"
},
"devDependencies": {
"@babel/types": "^7.21.5",
"@rushstack/eslint-patch": "^1.2.0",
"@rushstack/eslint-patch": "^1.3.0",
"@tsconfig/node-lts": "^18.12.2",
"@types/jsdom": "^21.1.1",
"@types/node": "^20.2.3",
"@types/webfontloader": "^1.6.35",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@vitejs/plugin-vue": "^4.2.3",
"@vitest/coverage-c8": "^0.31.1",
"@vue/eslint-config-prettier": "^7.1.0",
Expand Down Expand Up @@ -86,15 +86,15 @@
"rollup-plugin-visualizer": "^5.9.0",
"sass": "^1.62.1",
"stylelint": "^15.6.2",
"stylelint-config-recommended-scss": "^11.0.0",
"stylelint-config-recommended-scss": "^12.0.0",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-order": "^6.0.3",
"typescript": "*",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.3.8",
"vite-plugin-checker": "0.6.0",
"vite-plugin-vuetify": "^1.0.2",
"vitest": "^0.31.1",
"vitest": "^0.29.0",
"vue-eslint-parser": "^9.3.0",
"vue-tsc": "^1.7.0"
},
Expand Down
9 changes: 1 addition & 8 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ const isDark: ComputedRef<string> = computed(() =>
// When snackbar text has been set, show snackbar.
watch(
() => globalStore.message,
async message => {
snackbarVisibility.value = message !== '';
await nextTick();
}
message => (snackbarVisibility.value = message !== '')
);
/** Clear store when snackbar hide */
Expand All @@ -72,12 +69,8 @@ const onSnackbarChanged = async () => {
await nextTick();
};
// When loading overlay value change, force redraw screen.
watch(loading, async () => await nextTick());
onMounted(() => {
document.title = title;
loading.value = false;
});
</script>

Expand Down
87 changes: 37 additions & 50 deletions src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Vuetify3 Plugin
*/
// @ts-expect-error
import { createVuetify, type VuetifyOptions } from 'vuetify';
import { createVuetify, type VuetifyConfig } from 'vuetify';
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';
import { aliases, mdi } from 'vuetify/iconsets/mdi';
import * as labs from 'vuetify/labs/components';
import * as labsComponents from 'vuetify/labs/components';
// Translations provided by Vuetify
import { en } from 'vuetify/locale';

Expand All @@ -22,34 +22,12 @@ await loadFonts();
/**
* Vuetify Components
*
* Notice: This variable is used during development to load all components to speed up the display
* and to reduce the size during build.
*
* @see {@link https://vuetifyjs.com/en/labs/introduction/}
* @see {@link https://vuetifyjs.com/en/features/treeshaking/}
*/
const vuetifyComponents: VuetifyOptions = import.meta.env.DEV
? {
// For development
components: {
components,
...labs,
},
directives,
}
: {
// For production
components: {
components,
...labs,
},
};

export default createVuetify({
...vuetifyComponents,
...{
// Global configuration
// https://next.vuetifyjs.com/en/features/global-configuration/
/*
let vuetifyConfig: VuetifyConfig = {
// Global configuration
// https://vuetifyjs.com/en/features/global-configuration/
/*
defaults: {
global: {
ripple: false,
Expand All @@ -59,29 +37,38 @@ export default createVuetify({
},
},
*/
// Icon Fonts
// https://next.vuetifyjs.com/en/features/icon-fonts/
icons: {
defaultSet: 'mdi',
aliases,
sets: {
mdi,
},
},
// Internationalization (i18n)
// https://next.vuetifyjs.com/en/features/internationalization/#internationalization-i18n
locale: {
locale: 'en',
fallback: 'en',
messages: { en },
},
// Theme
// https://next.vuetifyjs.com/en/features/theme/
theme: {
defaultTheme: 'light',
// Icon Fonts
// https://vuetifyjs.com/en/features/icon-fonts/
icons: {
defaultSet: 'mdi',
aliases,
sets: {
mdi,
},
},
});
// Internationalization (i18n)
// https://vuetifyjs.com/en/features/internationalization/#internationalization-i18n
locale: {
locale: 'en',
fallback: 'en',
messages: { en },
},
// Theme
// https://vuetifyjs.com/en/features/theme/
theme: {
defaultTheme: 'light',
},
};

if (import.meta.env.DEV) {
// Disable treeshaking for DEV mode.
vuetifyConfig = {
components: { components, labsComponents },
directives,
...vuetifyConfig,
};
}
export default createVuetify(vuetifyConfig);

// Export for test.
export { components, directives };
16 changes: 6 additions & 10 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { nextTick } from 'vue';
import {
createRouter,
createWebHistory,
Expand All @@ -8,15 +7,15 @@ import {
type RouteRecordRaw,
} from 'vue-router';

// Pinia Store
// Components
import HomeView from '@/views/HomeView.vue';

// Pinia Store
import { useGlobal } from '@/store';

// Unimplemented in Vuetify 3.3.1
// import { goTo } from 'vuetify/lib/services/goto/index.mjs';

// Components

/** Router Rules */
const routes: RouteRecordRaw[] = [
{
Expand All @@ -43,16 +42,14 @@ const router: Router = createRouter({
*/
history: createWebHistory(import.meta.env.BASE_URL), // createWebHashHistory(import.meta.env.BASE_URL)
/*
// Unimplemented in Vuetify 3.1.6
scrollBehavior: (to, _from, savedPosition ) => {
scrollBehavior: (to, _from, savedPosition) => {
let scrollTo: number | string = 0;
if (to.hash) {
scrollTo = to.hash;
} else if (savedPosition) {
scrollTo = savedPosition.top;
}
return goTo(scrollTo);
},
*/
Expand All @@ -69,11 +66,10 @@ router.beforeEach(
) => {
const globalStore = useGlobal();
// Show Loading
globalStore.setLoading(true);
// comment out for https://github.com/logue/vite-vuetify-ts-starter/issues/16
// globalStore.setLoading(true);
// Hide snack bar
globalStore.setMessage('');
await nextTick();

next();
}
);
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineConfig(({ command, mode }): UserConfig => {
},
}),
// Vuetify Loader
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin#vite-plugin-vuetify
// https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin
vuetify({
autoImport: true,
styles: { configFile: 'src/styles/settings.scss' },
Expand Down Expand Up @@ -87,7 +87,7 @@ export default defineConfig(({ command, mode }): UserConfig => {
'vuetify',
'vuetify/components',
'vuetify/directives',
// 'vuetify/labs',
// 'vuetify/lib/labs',
'webfontloader',
],
materialdesignicons: ['@mdi/font/css/materialdesignicons.css'],
Expand Down
Loading

0 comments on commit bc0cbea

Please sign in to comment.