├── 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
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,我也遇到了这样的问题。
index.html
然后在
src/pages
vite.config.js
,您的配置可能看起来像:
root: './src/pages'