Comments (6)
Vite uses https://github.com/michael-ciniawsky/postcss-load-config so you can install Tailwind and add it to your postcss config's plugin list. It's working for me in Vitepress without any further tweaks!
from vitepress.
@neilmispelaar Sure, there's a few gotchas right now between Vite not supporting PostCSS 8 yet or being able to optimize certain dependencies.
https://github.com/ky-is/vitepress-starter-tailwind
Note that the order of import statements for vitepress/dist/client/theme-default
and tailwind.postcss
matters if you want to preserve VuePress's styles. I haven't really used the default theme, there might be a simpler way to import CSS if you aren't customizing it otherwise.
from vitepress.
Currently it doesn't seem like this is possible, but if you are okay with using the tailwind CDN it should be possible.
If you edit your config file in .vitepress/config.js
then you add the following to import tailwind
module.exports = {
head: [
['link', { rel: 'stylesheet', href='https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css' }]
]
};
I'm not sure how useful this will be for you if you are attempting to create a custom theme though.
from vitepress.
Thanks @jacobclevenger it was helpful. The project is under a heavy development, so let's hope this feature will become available at some point
from vitepress.
@ky-is
Would it be possible to share a code sample of how to get this to work?
I’ve tried integrating some code from the vite starter projects with tailwindcss working and sadly was getting errors when running the npm run docs:dev
command.
from vitepress.
Thank you so much! This was immensely helpful!
For anyone else that stumbles on this issue in the future a couple of things in regards to TailwindCSS and vitepress:
-
Make sure to put TailwindCss in the
package.json
under devDependencies (not dependencies). -
When you configure TailwindCSS, in the
tailwind.config.js
file you have to specify the hidden vitepress folders under the purge content list. If you just leave it as./docs/**/*.vue
nothing will be purged.
module.exports = {
purge: {
enabled: process.env.NODE_ENV === 'production',
content: [
'./docs/.vitepress/**/*.js',
'./docs/.vitepress/**/*.vue',
'./docs/.vitepress/**/*.ts',
],
options: {
safelist: ['html', 'body'],
}
}
}
- At time of writing, somewhere in the project dependencies
postCSS
version 7 is being referenced, but TailwindCSS usesPostCSS
version 8. This is why in yourpackage.json
you have to reference a version of TailwindCSS that is compatible withPostCSS
version 7. Fun Bonus: If you use this compatible version of TailwindCSS then you can not useAutoPrefixer
past version 9.
from vitepress.
Related Issues (20)
- Sidebar depth HOT 1
- upgrading to vitepress v1.2.2 build error HOT 2
- If I use the canonicalUrl example syntax in vitepress version 1.2.2, an error occurs when building. HOT 6
- Traslation issue HOT 4
- Add `important` to custom containers
- The style is not applied to the list inside the quote
- How to add a custom element next to a specific existing navbar element? HOT 1
- Last Updated Time in sitemap.xml HOT 1
- sidebar配置需要优化 HOT 3
- Markdown-it plugin type issue HOT 11
- Watch files in Path Loader
- (build): Number header attribute render error HOT 4
- Whether to support customizing the copy code text in the code box HOT 5
- Feature Request: Auto-generate Page Descriptions in VitePress for SEO Optimization HOT 3
- Hide the appearance switcher, but still honor the user’s preferred color scheme HOT 2
- Not support downloading local markdown file
- Why not support markdown region snippets? HOT 3
- 使用 AntDesignVue Pagination 组件中,发现单击某个页数切换,会导致页面会回滚到 Top HOT 3
- icon加载不出来时,用上一次离线缓存替换 HOT 1
- [New feature] export `VPHomeContent` to provide content-adaptive layout
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vitepress.