Skip to content
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

input.includes is not a function when add a css with object format in nuxt.config.js css property. #554

Closed
mena234 opened this issue Oct 29, 2022 · 2 comments · Fixed by #557
Labels
bug Something isn't working

Comments

@mena234
Copy link
Contributor

mena234 commented Oct 29, 2022

While I was upgrading an old Nuxt project, there are some CSS files declared in an object format in nuxt.config.js file.

For example.

css: [{ src: '~assets/scss/global', lang: 'scss' }]

When I installed the @nuxt/tailwindcss, I got an error "input.includes is not a function".

If I transform it to string format, it works fine.

For example.

css: ['~assets/scss/global.scss']

After some debugging, I found out that in the module file in the setup function, it expected to receive the nuxt.options.css as an array of strings only.

    nuxt.options.css = nuxt.options.css ?? []
    const resolvedNuxtCss = await Promise.all(nuxt.options.css.map((p) => resolvePath(p)))

I think it should check first if the option is in object format to pass the src attribute, or if it is in string format to pass it as it is.

something like that.

    nuxt.options.css = nuxt.options.css ?? []
    const resolvedNuxtCss = await Promise.all(nuxt.options.css.map((p) => resolvePath(p.src ?? p)))

I forked the project and added some changes to apply this and it worked for me.

https://github.com/mena234/tailwindcss/tree/Fix-Css-Option-In-Object-Format-Error

Version

"@nuxtjs/tailwindcss": "^5.3.3",
"nuxt": "^2.15.8",

Reproduction Link

https://codesandbox.io/s/gallant-rosalind-hq6ft4

Steps to reproduce

1- Create a new nuxt2 project
2- Install @nuxt/tailwindcss package.
3- Add a global CSS file with object format in the nuxt.config.js file

What is Expected?

Working with CSS object format.

What is actually happening?

Gives an error "input.includes is not a function"

@mena234 mena234 added the bug Something isn't working label Oct 29, 2022
@mena234 mena234 changed the title input.includes is not a function when push an css option in object format. input.includes is not a function when add a css with object format in nuxt.config.js css property. Oct 29, 2022
Copy link
Collaborator

atinux commented Nov 2, 2022

Nice found @mena234

Do you mind opening a PR?

@mena234
Copy link
Contributor Author

mena234 commented Nov 3, 2022

Nice found @mena234

Do you mind opening a PR?

Sure, please let me know if I missed something as it's my first contribution to an open-source package.

#557 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants