在构建过程中更改某些文件的输出路径-Vitejs

问题描述 投票:0回答:2

├── dist └──... └──src └── pages └── some-page.html └──... ├── node_modules ├── src └── pages └── some-page.html ├── .gitignore ├── index.html ├── package-lock.json ├── package.json └── vite.config.js 我想要:

├── dist └── ... └── some-page.html └── ... ├── node_modules ├── src └── pages └── some-page.html ├── .gitignore ├── index.html ├── package-lock.json ├── package.json └── vite.config.js

My Vite.Config.js(如文档所建议)是:
const { resolve } = require('path')
const { defineConfig } = require('vite')

module.exports = defineConfig({
    build: {
        rollupOptions: {
            input: {
                main: resolve(__dirname, 'index.html'),
                multiminerales: resolve(__dirname, 'src/pages/some-page.html')
            }
        }
    }
})

所以,我认为我需要更改输入对象,但是找不到有关它的任何信息,我知道公共目录,但它会破坏我的所有文件夹结构。我该怎么办?
	
您可以使用此配置-

import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' export default defineConfig({ root: resolve(path, 'templates'), base: 'https://aaronchristian.test/wp-content/themes/portfolio/', plugins: [vue(), vueJsx()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, build: { rollupOptions: { input: { index: fileURLToPath(new URL('./src/main.js', import.meta.url)), 'index.html': fileURLToPath(new URL('./templates/index.html', import.meta.url)) }, output: { dir: 'dist', entryFileNames: 'assets/[name].js', assetFileNames: 'assets/[name].[extname]', chunkFileNames: 'assets/[name].js' } } } })
    

Yeah,我也遇到了这样的问题。
build vite multi-page-application
2个回答
0
投票
index.html

然后在
src/pages

-1
投票
vite.config.js

,您的配置可能看起来像:

root: './src/pages'
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.