-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get it to work with Vite as dev server #1
Comments
I have an idea, but am just shutting down to go away for the weekend. Will try to look at it on Monday. |
OK, am ready to work on this, and am pretty sure I know what the issue (and fix) is. However, when I created a Vite demo project, everything seemed to work, but it could be I am missing something obvious in setup since I have no experience at all with Vite. package.json{
"name": "vite-project",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"@tailwindcss/forms": "^0.4.0",
"autoprefixer": "^10.4.2",
"tailwind-children": "^0.2.2",
"tailwindcss": "^3.0.23",
"vite": "^2.8.0"
} tailwind.config.jsconst forms = require('@tailwindcss/forms');
const defaultTheme = require('tailwindcss/defaultTheme');
const children = require('tailwind-children');
module.exports = {
content: [
'*.html',
'*.js'
],
theme: {
extend: {},
},
plugins: [
forms,
children,
],
} index.html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<link rel="stylesheet" type="text/css" href="./tw.css" media="print" onload="this.media='all';">
</head>
<body>
<div id="app" class="bg-blue-400 child:text-green-200"></div>
<script type="module" src="/main.js"></script>
</body>
</html> main.jsimport './style.css'
document.querySelector('#app').innerHTML = `
<h1 class='child'>Hello Vite!</h1>
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a> relevant commands (in two tabs)$ I get a page with the background set to blue, and the text of the header set to green. How can I reproduce the error? |
Thanks for taking a look! I'm gonna try to set up a repository which reproduces the bug so you can check that out. I'll update this comment when it's ready. --- Edit --- I've setup a basic repository which reproduces the bug for me: Some more info on node/npm versions just to be sure:
Something I notice in your example is that you include the .css file by yourself, in this setup, vite injects this within the header by itself, maybe its something related to that? Thanks! |
Ahh, I see. OK, hopefully will get this fixed today. As an aside, Github only sends an email when commenting, not when you edit your comment. So, I didn't realize you had edited your comment to say that you had made a reproducible build till last night. |
OK, just a short update, am still working on the "solution". The issue - tailwind-children is a ES Module (ESM). The solution - The issue - You can NOT directly import from fs paths in Vite. You need to use resolvers to do what you want to do. The solution - Hmmm, mayb you can help? I never used Vite before, and am still trying to figure it up. What are resolvers? |
Have merged #4 into this. Hopefully will have a chance to push at least a temp fix for this today. |
Just pushed a update that should solve the issue, but I have not yet tested at all. In addition it adds support for It is too late for me to work on this more tonight, but please test. |
@SamGoody -- i have the same problem. I can't get it to work within my Vite project with versions below: "@tailwindcss/line-clamp": "^0.4.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"tailwind-children": "^0.5.0",
"tailwindcss": "^3.0.24" |
Hey!
I stumbled upon this plugin after trying to get https://github.com/benface/tailwindcss-children to work with Tailwind v3.
The issue
I'm using Vite as my build tool and the moment I try to add tailwind-children as a plugin my project just keeps on loading and times out after a bit.
My
tailwind.config.js
contains the following:When I remove the plugin and restart my Vite dev server everything works as expected again.
Package versions
The installed versions of the plugin, Vite and Tailwind are as follows within the package.json:
Possible solution
Might be a wild guess, but maybe Vite can't process
.mjs
or.cjs
files? I saw these being used in thesrc
directory.Thanks in advance and if you need more information, please ask and i'll try to provide it 😄
The text was updated successfully, but these errors were encountered: