How to decrease the directory hierarchy of the output of html files in Vite.js?

Viewed 47

I have built an MPA project based on vite. And I put the templates in src/pages/. When I run dev or build, it will output something like /pages/list/index.html.But I don‘t need the router pages. How can I get the output like /pages/list/index.html?

The vite.config.ts is like below,

const root = path.resolve(__dirname, 'src');
const pageDir = path.resolve(root, 'pages')
const outDir = path.resolve(__dirname, 'dist');
    export default defineConfig({
      root,
      plugins: [
        react(),
        copy({
          targets: [{ src: 'src/lib/**/*', dest: 'dist/lib' }],
          hook: 'writeBundle'
        }),
      ],
      build: {
        outDir,
        emptyOutDir: true,
        rollupOptions: {
          input: {
            list:   path.resolve(pageDir, 'list/index.html'),
            filter: path.resolve(pageDir, 'filter/index.html'),
            result: path.resolve(pageDir, 'result/index.html'),
            search: path.resolve(pageDir, 'search/index.html'),
          }
        },
      },
      resolve: {
        alias: [
          {
            find: /@\//,
            replacement: path.join(__dirname, './src/')
          }
        ]
      },
      css: {
        "preprocessorOptions": {
          "less": {
            "javascriptEnabled": true
          }
        },
        "modules": {
          "localsConvention": "camelCase"
        }
      }
    })

0 Answers
Related