如何解决这个问题
我不想将index.html放在tailwindcss目录中。
Vite 默认查找根
index.html
。您可以在 package.json
中更改此行为。
为此,只需修改以下内容以适应...
"scripts": {
"dev": "vite serve ./src"
},
在此示例中,我将条目
index.html
文件放入 src
文件夹中。我通过serve
告诉Vite这一点,然后是相关目录(文件路径相对于项目根目录)。
阅读更多这里。
您可以尝试显式指定 Rollup 使用的入口点:
// vite.config.ts
export default {
build: {
rollupOptions: {
input: {
// entry point for compilation; normally would be "./index.html"
app: '../index.html',
但说实话,感觉就像你在与工具作斗争,你应该在你的项目中拥有
package.json
一个目录。
Vite 有一个直接配置选项,可以在 vite.config.js 中指定。
https://vitejs.dev/config/shared-options.html#root
export default defineConfig({
root: 'src',
build: {
// Relative to the root
outDir: '../dist',
},
});