lstoeferle / vite-vue2-starter

Vite - Vue 2 starter template using composition-api and windiCSS
MIT License
196 stars 38 forks source link

I wannt to change it to multi-page app,but get 404 . #9

Closed jackchoumine closed 2 years ago

jackchoumine commented 2 years ago

my vite config according vite docs

import path from 'path'
import { defineConfig } from 'vite'
import { createVuePlugin as Vue2 } from 'vite-plugin-vue2'
import WindiCSS from 'vite-plugin-windicss'
import Components from 'unplugin-vue-components/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import ScriptSetup from 'unplugin-vue2-script-setup/vite'
import AutoImport from 'unplugin-auto-import/vite'

const root = path.resolve(__dirname, 'src')
const outDir = path.resolve(__dirname, 'dist')

const config = defineConfig({
  // root,
  resolve: {
    alias: {
      '@': `${path.resolve(__dirname, 'src')}`,
    },
    dedupe: ['vue-demi'],
  },

  build: {
    // outDir,
    minify: true,
    rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'index.html'),
        about: path.resolve(__dirname, 'about', 'index.html'),
      },
    },
  },

  plugins: [
    Vue2(),
    ScriptSetup(),
    WindiCSS(),
    Components({
      resolvers: [
        IconsResolver({
          componentPrefix: '',
        }),
      ],
      dts: 'src/components.d.ts',
    }),
    Icons(),
    AutoImport({
      imports: ['@vue/composition-api', 'vue-router', '@vueuse/core'],
      dts: 'src/auto-imports.d.ts',
    }),
  ],

  server: {
    port: 3333,
  },
})

export default config

image

open about path :http://localhost:3333/about it is 404.

How can i fix it?

lstoeferle commented 2 years ago

Hey @jackchoumine, this Vite feature is new to me. I'll have a look 👍

lstoeferle commented 2 years ago

Hey @jackchoumine, looks like you're not able to nest the page inside of the src directory.

It's working if you move <root-dir>/src/about ➡️ <root-dir>/about 😉 (like in the docs)