diff --git a/docs/guide/icons/unocss-preset-icons.md b/docs/guide/icons/unocss-preset-icons.md index 64adf1e..5d64709 100644 --- a/docs/guide/icons/unocss-preset-icons.md +++ b/docs/guide/icons/unocss-preset-icons.md @@ -93,7 +93,7 @@ export default defineNuxtConfig({ icons: { defaultSet: 'unocss-mdi', unocssIcons: { - // default is i-mdi:close-circle + // default is i-mdi:close-circle delete: 'i-mdi:close-circle-outline', // even from another collection, default is i-mdi:chevron-up collapse: 'i-tabler:chevron-up' diff --git a/docs/guide/index.md b/docs/guide/index.md index da5a833..da52413 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -121,7 +121,7 @@ export interface MOptions { } /** * Add Vuetify Vite Plugin `transformAssetsUrls`? - * + * * You can extend the Vuetify `transformAssetsUrls`. * * @default true @@ -198,7 +198,7 @@ export interface MOptions { * @default false */ prefersReducedMotion?: boolean - } + } } ``` diff --git a/docs/guide/server-side-rendering.md b/docs/guide/server-side-rendering.md index 08c8978..5b767ec 100644 --- a/docs/guide/server-side-rendering.md +++ b/docs/guide/server-side-rendering.md @@ -31,7 +31,7 @@ export default defineNuxtConfig({ }, vuetifyOptions: { /* vuetify options */ - } + } }, experimental: { inlineSSRStyles: false diff --git a/package.json b/package.json index cd60dc5..81d845e 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "*.mjs" ], "scripts": { - "prepack": "nuxt-module-build", + "prepack": "nuxt-module-build prepare && nuxt-module-build", "dev": "nuxi dev playground", "dev:multiple-json": "MULTIPLE_LANG_FILES=true nuxi dev playground", "dev:prepare": "nuxt-module-build --stub && nuxt-module-build prepare && nuxi prepare playground", @@ -65,7 +65,11 @@ "dependencies": { "@nuxt/kit": "^3.6.2", "defu": "^6.1.2", + "destr": "^2.0.2", + "local-pkg": "^0.5.0", + "pathe": "^1.1.1", "perfect-debounce": "^1.0.0", + "ufo": "^1.3.1", "unconfig": "^0.3.9", "vite-plugin-vuetify": "^1.0.2", "vuetify": "^3.3.23" diff --git a/playground/main.scss b/playground/assets/main.scss similarity index 100% rename from playground/main.scss rename to playground/assets/main.scss diff --git a/playground/settings.scss b/playground/assets/settings.scss similarity index 100% rename from playground/settings.scss rename to playground/assets/settings.scss diff --git a/playground/config/i18n.ts b/playground/config/i18n.ts index ea48047..df18527 100644 --- a/playground/config/i18n.ts +++ b/playground/config/i18n.ts @@ -1,3 +1,4 @@ +import process from 'node:process' import type { DateTimeFormats, NumberFormats, PluralizationRules } from '@intlify/core-base' import type { LocaleObject } from '#i18n' diff --git a/playground/nuxt.config.mts b/playground/nuxt.config.mts index 7c51ba9..742d8aa 100644 --- a/playground/nuxt.config.mts +++ b/playground/nuxt.config.mts @@ -48,67 +48,9 @@ export default defineNuxtConfig({ }, viewportSize: true, }, - // styles: { configFile: '/settings.scss' }, + // styles: { configFile: 'assets/settings.scss' }, }, }, - // vuetify: { - /* moduleOptions: { - styles: { configFile: '/settings.scss' }, - }, */ - // vuetifyOptions: './vuetify.config.mts', - /* vuetifyOptions: { - ssr: { - clientWidth: 100, - }, - aliases: { - MyBadge: 'VBadge', - }, - directives: true, - components: ['VDialog', 'VExpansionPanel', 'VExpansionPanelText', 'VExpansionPanelTitle'], - labComponents: ['VDataTable', 'VDatePickerControls', 'VDatePickerHeader'], - blueprint: md3, - /!*locale: { - messages: { - en: { - hello: 'Hi', - question: { - one: 'One', - two: 'Two', - }, - }, - es: { - hello: 'Hola', - question: { - one: 'Uno', - two: 'Dos', - three: 'Tres', - }, - }, - }, - }, - localeMessages: ['en', 'es', 'ar'],*!/ - theme: { - defaultTheme: 'light', - }, - date: { - adapter: 'luxon', - // adapter: 'vuetify', - }, - icons: { - // remember to comment the v-icon in playground/pages/index.vue when switching - // defaultSet: 'fa-svg', - defaultSet: 'unocss-mdi', - // defaultSet: 'mdi-svg', - /!*svg: { - mdi: { - aliases: { - account: 'mdiAccount', - }, - }, - },*!/ - }, - }, */ - // }, vite: { clearScreen: false, define: { @@ -140,7 +82,7 @@ export default defineNuxtConfig({ }, }, // css: ['vuetify/styles'], - // css: ['/main.scss'], + // css: ['~/assets/main.scss'], experimental: { inlineSSRStyles: false, payloadExtraction: false, diff --git a/playground/pages/index.vue b/playground/pages/index.vue index a5bb5e3..1e4b083 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -16,6 +16,7 @@ const { locales, t } = useI18n() const { current } = useLocale() const { isRtl } = useRtl() +// eslint-disable-next-line n/prefer-global/process if (process.client) { // eslint-disable-next-line no-console console.log(useNuxtApp().$vuetify.icons) diff --git a/playground/plugins/vuetify.ts b/playground/plugins/vuetify.ts index 2be809e..c1f00c7 100644 --- a/playground/plugins/vuetify.ts +++ b/playground/plugins/vuetify.ts @@ -1,14 +1,17 @@ export default defineNuxtPlugin((nuxtApp) => { nuxtApp.hook('vuetify:before-create', ({ isDev, vuetifyOptions }) => { + // eslint-disable-next-line n/prefer-global/process if (process.client && isDev) { // eslint-disable-next-line no-console console.log('vuetify:plugin:hook', vuetifyOptions) } }) nuxtApp.hook('vuetify:ready', () => { + // eslint-disable-next-line no-console console.log('vuetify:ready') }) nuxtApp.hook('vuetify:ssr-client-hints', ({ ssrClientHints }) => { + // eslint-disable-next-line no-console console.log('vuetify:ssr-client-hints', ssrClientHints) }) }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1bdd8dc..f370226 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,21 @@ importers: defu: specifier: ^6.1.2 version: 6.1.2 + destr: + specifier: ^2.0.2 + version: 2.0.2 + local-pkg: + specifier: ^0.5.0 + version: 0.5.0 + pathe: + specifier: ^1.1.1 + version: 1.1.1 perfect-debounce: specifier: ^1.0.0 version: 1.0.0 + ufo: + specifier: ^1.3.1 + version: 1.3.1 unconfig: specifier: ^0.3.9 version: 0.3.9 @@ -2619,7 +2631,7 @@ packages: pkg-types: 1.0.3 scule: 1.0.0 semver: 7.5.4 - ufo: 1.3.0 + ufo: 1.3.1 unctx: 2.3.1 unimport: 3.3.0(rollup@3.26.3) untyped: 1.4.0 @@ -2657,7 +2669,7 @@ packages: pkg-types: 1.0.3 postcss-import-resolver: 2.0.0 std-env: 3.3.3 - ufo: 1.1.2 + ufo: 1.3.1 unimport: 3.1.0(rollup@3.26.3) untyped: 1.3.2 transitivePeerDependencies: @@ -2675,7 +2687,7 @@ packages: pkg-types: 1.0.3 postcss-import-resolver: 2.0.0 std-env: 3.4.3 - ufo: 1.3.0 + ufo: 1.3.1 unimport: 3.3.0(rollup@3.26.3) untyped: 1.4.0 transitivePeerDependencies: @@ -2693,7 +2705,7 @@ packages: consola: 3.2.3 create-require: 1.1.1 defu: 6.1.2 - destr: 2.0.0 + destr: 2.0.2 dotenv: 16.3.1 fs-extra: 11.1.1 git-url-parse: 13.1.0 @@ -2735,7 +2747,7 @@ packages: get-port-please: 3.0.1 ofetch: 1.1.1 pathe: 1.1.1 - ufo: 1.1.2 + ufo: 1.3.1 vitest: 0.31.4(sass@1.63.6) vue: 3.3.7(typescript@5.2.2) transitivePeerDependencies: @@ -2786,7 +2798,7 @@ packages: rollup-plugin-visualizer: 5.9.2(rollup@3.26.3) std-env: 3.3.3 strip-literal: 1.0.1 - ufo: 1.1.2 + ufo: 1.3.1 unplugin: 1.4.0 vite: 4.3.9(@types/node@18.0.0)(sass@1.63.6) vite-node: 0.33.0(@types/node@18.0.0)(sass@1.63.6) @@ -2832,7 +2844,7 @@ packages: mlly: 1.4.2 pathe: 1.1.1 pkg-types: 1.0.3 - ufo: 1.3.0 + ufo: 1.3.1 unplugin: 1.5.0 unstorage: 1.9.0 vue-i18n: 9.4.1(vue@3.3.7) @@ -3245,7 +3257,7 @@ packages: deepmerge: 4.3.1 is-builtin-module: 3.2.1 is-module: 1.0.0 - resolve: 1.22.2 + resolve: 1.22.3 rollup: 3.26.3 dev: true @@ -5843,12 +5855,8 @@ packages: engines: {node: '>= 0.8'} dev: true - /destr@2.0.0: - resolution: {integrity: sha512-FJ9RDpf3GicEBvzI3jxc2XhHzbqD8p4ANw/1kPsFBfTvP1b7Gn/Lg1vO7R9J4IVgoMbyUmFrFGZafJ1hPZpvlg==} - - /destr@2.0.1: - resolution: {integrity: sha512-M1Ob1zPSIvlARiJUkKqvAZ3VAqQY6Jcuth/pBKQ2b1dX/Qx0OnJ8Vux6J2H5PTMQeRzWrrbTu70VxBfv/OPDJA==} - dev: true + /destr@2.0.2: + resolution: {integrity: sha512-65AlobnZMiCET00KaFFjUefxDX0khFA/E4myqZ7a6Sq1yZtR8+FVIvilVX66vF2uobSumxooYZChiRPCKNqhmg==} /destroy@1.2.0: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} @@ -6647,7 +6655,7 @@ packages: enhanced-resolve: 5.15.0 mlly: 1.4.0 pathe: 1.1.1 - ufo: 1.1.2 + ufo: 1.3.1 dev: true /fast-deep-equal@3.1.3: @@ -7164,10 +7172,10 @@ packages: dependencies: cookie-es: 1.0.0 defu: 6.1.2 - destr: 2.0.0 + destr: 2.0.2 iron-webcrypto: 0.7.1 radix3: 1.0.1 - ufo: 1.1.2 + ufo: 1.3.1 uncrypto: 0.1.3 dev: true @@ -7176,10 +7184,10 @@ packages: dependencies: cookie-es: 1.0.0 defu: 6.1.2 - destr: 2.0.1 + destr: 2.0.2 iron-webcrypto: 0.8.2 radix3: 1.1.0 - ufo: 1.3.0 + ufo: 1.3.1 uncrypto: 0.1.3 unenv: 1.7.4 dev: true @@ -7974,7 +7982,7 @@ packages: mlly: 1.4.0 node-forge: 1.3.1 pathe: 1.1.1 - ufo: 1.1.2 + ufo: 1.3.1 dev: true /listhen@1.5.0: @@ -7994,7 +8002,7 @@ packages: mlly: 1.4.2 node-forge: 1.3.1 pathe: 1.1.1 - ufo: 1.3.0 + ufo: 1.3.1 untun: 0.1.2 uqr: 0.1.2 dev: true @@ -8008,6 +8016,14 @@ packages: resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} engines: {node: '>=14'} + /local-pkg@0.5.0: + resolution: {integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==} + engines: {node: '>=14'} + dependencies: + mlly: 1.4.2 + pkg-types: 1.0.3 + dev: false + /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -8441,7 +8457,7 @@ packages: acorn: 8.10.0 pathe: 1.1.1 pkg-types: 1.0.3 - ufo: 1.1.2 + ufo: 1.3.1 /mlly@1.4.2: resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} @@ -8449,7 +8465,7 @@ packages: acorn: 8.10.0 pathe: 1.1.1 pkg-types: 1.0.3 - ufo: 1.3.0 + ufo: 1.3.1 /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} @@ -8529,7 +8545,7 @@ packages: consola: 3.2.3 cookie-es: 1.0.0 defu: 6.1.2 - destr: 2.0.0 + destr: 2.0.2 dot-prop: 7.2.0 esbuild: 0.18.16 escape-string-regexp: 5.0.0 @@ -8567,7 +8583,7 @@ packages: serve-static: 1.15.0 source-map-support: 0.5.21 std-env: 3.3.3 - ufo: 1.1.2 + ufo: 1.3.1 uncrypto: 0.1.3 unenv: 1.5.2 unimport: 3.1.0(rollup@3.26.3) @@ -8847,7 +8863,7 @@ packages: chokidar: 3.5.3 cookie-es: 1.0.0 defu: 6.1.2 - destr: 2.0.0 + destr: 2.0.2 devalue: 4.3.2 esbuild: 0.18.16 escape-string-regexp: 5.0.0 @@ -8872,7 +8888,7 @@ packages: prompts: 2.4.2 scule: 1.0.0 strip-literal: 1.0.1 - ufo: 1.1.2 + ufo: 1.3.1 ultrahtml: 1.3.0 uncrypto: 0.1.3 unctx: 2.3.1 @@ -8956,17 +8972,17 @@ packages: /ofetch@1.1.1: resolution: {integrity: sha512-SSMoktrp9SNLi20BWfB/BnnKcL0RDigXThD/mZBeQxkIRv1xrd9183MtLdsqRYLYSqW0eTr5t8w8MqjNhvoOQQ==} dependencies: - destr: 2.0.0 + destr: 2.0.2 node-fetch-native: 1.2.0 - ufo: 1.1.2 + ufo: 1.3.1 dev: true /ofetch@1.3.3: resolution: {integrity: sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==} dependencies: - destr: 2.0.1 + destr: 2.0.2 node-fetch-native: 1.4.0 - ufo: 1.3.0 + ufo: 1.3.1 dev: true /ohash@1.1.2: @@ -9733,7 +9749,7 @@ packages: resolution: {integrity: sha512-lNeOl38Ws0eNxpO3+wD1I9rkHGQyj1NU1jlzv4go2CtEnEQEUfqnIvZG7W+bC/aXdJ27n5x/yUjb6RoT9tko+Q==} dependencies: defu: 6.1.2 - destr: 2.0.0 + destr: 2.0.2 flat: 5.0.2 /rc@1.2.8: @@ -9937,15 +9953,6 @@ packages: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} dev: true - /resolve@1.22.2: - resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==} - hasBin: true - dependencies: - is-core-module: 2.12.1 - path-parse: 1.0.7 - supports-preserve-symlinks-flag: 1.0.0 - dev: true - /resolve@1.22.3: resolution: {integrity: sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw==} hasBin: true @@ -10994,11 +11001,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - /ufo@1.1.2: - resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} - - /ufo@1.3.0: - resolution: {integrity: sha512-bRn3CsoojyNStCZe0BG0Mt4Nr/4KF+rhFlnNXybgqt5pXHNFRlqinSoQaTrGyzE4X8aHplSb+TorH+COin9Yxw==} + /ufo@1.3.1: + resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} /ultrahtml@1.3.0: resolution: {integrity: sha512-xmXvE8tC8t4PVqy0/g1fe7H9USY/Brr425q4dD/0QbQMQit7siCtb06+SCqE4GfU24nwsZz8Th1g7L7mm1lL5g==} @@ -11359,7 +11363,7 @@ packages: dependencies: anymatch: 3.1.3 chokidar: 3.5.3 - destr: 2.0.0 + destr: 2.0.2 h3: 1.7.1 ioredis: 5.3.2 listhen: 1.1.2 @@ -11367,7 +11371,7 @@ packages: mri: 1.2.0 node-fetch-native: 1.2.0 ofetch: 1.1.1 - ufo: 1.1.2 + ufo: 1.3.1 transitivePeerDependencies: - supports-color dev: true @@ -11412,7 +11416,7 @@ packages: dependencies: anymatch: 3.1.3 chokidar: 3.5.3 - destr: 2.0.1 + destr: 2.0.2 h3: 1.8.1 ioredis: 5.3.2 listhen: 1.5.0 @@ -11420,7 +11424,7 @@ packages: mri: 1.2.0 node-fetch-native: 1.4.0 ofetch: 1.3.3 - ufo: 1.3.0 + ufo: 1.3.1 transitivePeerDependencies: - supports-color dev: true @@ -11972,7 +11976,7 @@ packages: /vue-bundle-renderer@1.0.3: resolution: {integrity: sha512-EfjX+5TTUl70bki9hPuVp+54JiZOvFIfoWBcfXsSwLzKEiDYyHNi5iX8srnqLIv3YRnvxgbntdcG1WPq0MvffQ==} dependencies: - ufo: 1.1.2 + ufo: 1.3.1 dev: true /vue-demi@0.13.11(vue@3.3.7): @@ -12066,7 +12070,7 @@ packages: '@intlify/shared': 9.4.1 '@intlify/vue-i18n-bridge': 1.0.1(vue-i18n@9.4.1) '@intlify/vue-router-bridge': 1.0.1(vue@3.3.7) - ufo: 1.3.0 + ufo: 1.3.1 vue: 3.3.7(typescript@5.2.2) vue-demi: 0.14.5(vue@3.3.7) vue-i18n: 9.4.1(vue@3.3.7) diff --git a/src/types.ts b/src/types.ts index 848457d..9b39f3d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -409,8 +409,7 @@ declare module '@nuxt/schema' { } } -declare module '#app' { - // TODO: fix this issue upstream in nuxt/module-builder +declare module '#app/nuxt' { interface NuxtApp { $vuetify: ReturnType /** diff --git a/src/vite/vuetify-import-plugin.ts b/src/vite/vuetify-import-plugin.ts index 8311679..6bcb8a5 100644 --- a/src/vite/vuetify-import-plugin.ts +++ b/src/vite/vuetify-import-plugin.ts @@ -22,12 +22,12 @@ function parseId(id: string) { } } -export function vuetifyImportPlugin(): Plugin { - return { - name: 'vuetify:import', +export function vuetifyImportPlugin() { + return { + name: 'vuetify:import:nuxt', configResolved(config) { - if (config.plugins.findIndex(plugin => plugin.name === 'vuetify:import') < config.plugins.findIndex(plugin => plugin.name === 'vite:vue')) - throw new Error('Vuetify plugin must be loaded after the vue plugin') + if (config.plugins.findIndex(plugin => plugin.name === 'vuetify:import') > -1) + throw new Error('Remove vite-plugin-vuetify from your Nuxt config file, this module registers a modified version.') }, async transform(code, id) { const { query, path } = parseId(id) diff --git a/src/vite/vuetify-styles-plugin.ts b/src/vite/vuetify-styles-plugin.ts index 4477f72..6ad631c 100644 --- a/src/vite/vuetify-styles-plugin.ts +++ b/src/vite/vuetify-styles-plugin.ts @@ -17,7 +17,7 @@ const styleImportRegexp = /(@use |meta\.load-css\()['"](vuetify(?:\/lib)?(?:\/st export function vuetifyStylesPlugin( options: Options, logger: ReturnType, -): Plugin { +) { const vuetifyBase = resolveVuetifyBase() const files = new Set() @@ -146,6 +146,9 @@ export function vuetifyStylesPlugin( } }, configResolved(config) { + if (config.plugins.findIndex(plugin => plugin.name === 'vuetify:styles') > -1) + throw new Error('Remove vite-plugin-vuetify from your Nuxt config file, this module registers a modified version.') + if (typeof options.styles === 'object') { if (isAbsolute(options.styles.configFile)) configFile = options.styles.configFile