-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
tailwind triggers nuxt.config
import protection
#13278
Comments
Sorry for the inconvenience. Regression should be fixed by nuxt/framework#2885 (in a few minutes, you can upgrade using |
|
@shahabbasian And are you importing from |
Hi @danielroe, Don't have the time for a repo at this moment, but the only thing I was importing was import { defineNuxtConfig } from 'nuxt3' |
@rvmourik That issue should be fixed: https://stackblitz.com/edit/github-t46bjg?file=package.json&terminal=dev |
I reverted back, so I just did:
> Local: http://localhost:3000/
> Network: http://x.x.x.x:3000/
> Network: http://x.x.x.x:3000/
ℹ Nested components option detected nuxt:storm 16:16:18
ℹ 48 components compiled for nuxt-storm nuxt:storm 16:16:18
ℹ Vite warmed up in 123ms 16:16:19
ERROR Importing directly from a nuxt.config file is not allowed. Instead, use runtime config or a module. [importing /nuxt.config.ts from index.html] nuxt.config.ts import { defineNuxtConfig } from 'nuxt3';
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
meta: {
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
],
link: [
{ href: 'https://rsms.me/inter/inter.css' },
{ rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' },
{ rel: 'alternate icon', href: '/favicon.ico' }
],
script: [{ src: '/assets/js/vite-amplify-fix.js' }]
},
buildModules: [
'@vueuse/nuxt',
'@pinia/nuxt',
[
'@intlify/nuxt3',
{
vueI18n: {
locale: 'nl'
}
}
],
['nuxt-storm', { nested: true }]
],
vueuse: {
ssrHandler: true
},
build: {
postcss: {
postcssOptions: {
plugins: {
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {}
}
}
}
},
vite: {
resolve: {
alias: {
'./runtimeConfig': './runtimeConfig.browser'
}
}
}
}); Thanks in advance |
@rvmourik Any chance |
narrowed it down to tailwindcss postcss plugin I thinks, if I comment this out and start the dev environment the error is not present. build: {
postcss: {
postcssOptions: {
plugins: {
'tailwindcss/nesting': {},
// tailwindcss: {}
autoprefixer: {}
}
}
}
}, With this, no error. |
I see this problem by adding the tailwindcss file |
nuxt.config
import protection
For now, remove the content: [
"./components/**/*.{vue,js}",
"./layouts/**/*.vue",
"./pages/**/*.vue",
"./app.vue",
"./plugins/**/*.{js,ts}",
- "./nuxt.config.{js,ts}"
],
theme: {
extend: {
fontFamily: {
vazir: ['Vazir']
}
},
},
plugins: [],
} Do you think you need Tailwind to scan your nuxt.config? |
@danielroe I had only seen these settings in training for a long time |
No i don't think so either, I got it from here. https://tailwindcss.nuxtjs.org/tailwind/config#default-configuration |
PR send to TailwindLabs docs tailwindlabs/tailwindcss.com#1160 |
@danielroe I had also seen that from the official tailwind documentation site here https://tailwindcss.com/docs/guides/nuxtjs |
Hey folks! So the main reason we need to include |
@danielroe you need to correct me if I am saying something that isn't true. @reinink for Nuxt 2 this is the case, with Nuxt 3 it is possible to set those through the info found here: https://v3.nuxtjs.org/docs/usage/meta-tags So the need to scan the config might not be necessary anymore. |
A point to note on what @rvmourik suggests. I added the |
I changed from |
Removing |
@pi0 I tried with @nuxtjs/tailwindcss 5 but in chrome dev I am getting a following error Hydration completed but contains mismatches. |
I am facing the same issue. I try what you suggested above but did not work. |
@adityar15 Would you please open an issue possibly with reproduction in repo? |
@pi0 Thanks for the comment. I was able to sort it for now. Just need to delete package-lock.json and just did npm install. |
I also had this issue while setting up tailwindcss |
Delete
|
Also if you are customizing the Like this: module.exports = {
content: [
'components/**/*.{vue,js}',
'layouts/**/*.vue',
'pages/**/*.vue',
'plugins/**/*.{js,ts}',
'app.vue',
'error.vue' // or '*.vue'
],
theme: {
extend: {},
},
plugins: [],
} |
One of the glob patterns under
I don't know why this happens - is Vite actually trying to bundle in everything that it finds with the |
Thank you, the removal of nuxt.config in tailiwnd works. weird why should tailwind scan it. |
/cc @danielroe We need to do something for this :) |
Any updates regarding this? It would be nice if nuxt.config.ts and other files could be scanned for Tailwind classes without making them bundled or treating them like code that is about to be bundled (e.g. analyzing imports, throwing errors if the imports don't resolve) |
Better solution is to define // app.vue
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
<script lang="ts" setup>
useHead({
bodyAttrs: {
class: 'h-full font-body antialiased',
},
htmlAttrs: {
class: 'min-h-full',
lang: 'en',
},
})
</script> // tailwind.config.js
module.exports = {
content: [
'components/**/*.vue',
'layouts/**/*.vue',
'pages/**/*.vue',
'app.vue',
'error.vue',
],
} |
Environment
RootDir: /home/supp/code/test
Nuxt project info:
Linux
v17.4.0
3.0.0-27383858.03cc191
yarn@1.22.17
Vite
-
-
-
Reproduction
https://stackblitz.com/edit/github-vaufyy?devtoolsheight=33&file=package.json
Describe the bug
I just create a new clear project with
npx nuxi create
and tried to runyarn dev
Errors compilng:
nuxt3/nuxt cannot be imported directly. Instead, import runtime Nuxt composables from #app or #imports. [importing /home/supp/code/test/node_modules/nuxt3/dist/meta/runtime/plugin from virtual:/home/supp/code/test/.nuxt/plugins/server.mjs]
This module cannot be imported in the Vue part of your app. [importing /home/supp/code/test/node_modules/@nuxt/nitro/dist/runtime/app/nitro.client.mjs from virtual:/home/supp/code/test/.nuxt/plugins/server.mjs]
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: