antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.34k stars 136 forks source link

error ssg build when add vuetify #257

Open motercode opened 2 years ago

motercode commented 2 years ago

error

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for /home/fernando/workspace/vitevue/node_modules/.pnpm/vuetify@3.0.0-beta.0_vue-i18n@9.1.10+vue@3.2.36/node_modules/vuetify/lib/styles/main.css

repeat:

get a fresh vitesse project add on vite.config.ts

import {  Vuetify3Resolver} from 'unplugin-vue-components/resolvers'

 components.resolvers: [
        Vuetify3Resolver(),
      ],
pnpm i @mdi/font@6.7.96
pnpm i vuetify@3.0.0-beta.0

create file vuetify.ts on /src/modules with this content

import '@mdi/font/css/materialdesignicons.css'
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
import { type UserModule } from '~/types'
export const install: UserModule = ({ app }) => {
  const vuetify = createVuetify()
  app.use(vuetify)
}

pnpm build

i tried to use custom route to render ssg to avoid the files on vuetify following the idea of this comment #156 to just ignore those with this code on vite.config.ts

ssgOptions: {
    includedRoutes(paths, routes) {
      return paths.filter(i => !i.includes('vuetify'))
    },
  },

seems includedRoutes does nothing.

josh-hemphill commented 2 years ago

For me, following the suggestion in the issue in Vite itself worked.

// vite.config.js
import vuetify from 'vite-plugin-vuetify';

/** @type {import('vite').UserConfig} */
const config = {
    plugins: [vuetify()],
    ssr: {
        noExternal: ['vuetify']
    },
};
export default config;