尝试构建一个简单的Vite项目,其中包含tailwindcss,并得到以下错误,有什么想法吗?
> vite-project@0.0.0 build
> vite build
vite v2.3.4 building for production...
✓ 1 modules transformed.
[vite]: Rollup failed to resolve import "style.css" from "index.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "style.css" from "index.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
at onRollupWarning (/Users/jmansfield/Sites/vite-project/node_modules/vite/dist/node/chunks/dep-6b5f3ba8.js:45022:19)
at Object.onwarn (/Users/jmansfield/Sites/vite-project/node_modules/vite/dist/node/chunks/dep-6b5f3ba8.js:44812:13)
at Object.onwarn (/Users/jmansfield/Sites/vite-project/node_modules/rollup/dist/shared/rollup.js:20122:20)
at ModuleLoader.handleResolveId (/Users/jmansfield/Sites/vite-project/node_modules/rollup/dist/shared/rollup.js:19143:26)
at /Users/jmansfield/Sites/vite-project/node_modules/rollup/dist/shared/rollup.js:19097:22
at async Promise.all (index 0)
at async ModuleLoader.fetchStaticDependencies (/Users/jmansfield/Sites/vite-project/node_modules/rollup/dist/shared/rollup.js:19095:34)
at async Promise.all (index 0)
at async ModuleLoader.fetchModule (/Users/jmansfield/Sites/vite-project/node_modules/rollup/dist/shared/rollup.js:19071:9)
at async Promise.all (index 0)```发布于 2021-09-14 00:14:23
这是因为vite:rollup安装程序中的build.rollupOptions.external在查找外部文件之前查找/。因此,当您添加css文件到您的html时,只需添加'/‘(例如,/src/foo.css而不是src/foo.css)
发布于 2021-06-01 14:30:54
基本上,vite找不到您在html中引用的css文件。当我遇到这个问题时,我改变了在html中引用css文件的方式。我在路径中添加或删除了./。
https://stackoverflow.com/questions/67696920
复制相似问题