question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

config.content should be resolved relative to the config file for PostCSS dependencies

See original GitHub issue

What version of Tailwind CSS are you using?

v3.0.2

What build tool (or framework if it abstracts the build tool) are you using?

Parcel 2 👋

What version of Node.js are you using?

16

What operating system are you using?

macOS

Describe your issue

If you have a tailwind config file like

module.exports = {
    content: ["index.html"],
    theme: {
        extend: {},
    },
    plugins: [],
}

, I think content should be relative to that config file.

However, it is resolved relative to the process’s working directory.

fileOrGlob here is “index.html”.

https://github.com/tailwindlabs/tailwindcss/blob/a7263a8f6faf989cb98553491d5c456d0b86de9b/src/lib/setupTrackingContext.js#L160

and then path.resolve(file) resolved it relative to the cwd. It should be path.resolve(path.dirname(configPath), file) instead:

https://github.com/tailwindlabs/tailwindcss/blob/a7263a8f6faf989cb98553491d5c456d0b86de9b/src/util/parseDependency.js#L37-L39

This results in a PostCSS dependency message with a filepath of ${cwd}/index.html, regardless of where that file is actually located.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
k33n8nccommented, Apr 14, 2022

This is a problem for Wordpress themes also where all template files live in the root folder.

1reaction
sibiraj-srcommented, Jan 27, 2022

This is an issue in angular workspaces as well. Having tailwind.config.js in one of the project doesn’t resolve relative paths correctly after updating to v3. One has to provide full path from the root.

config file path: projects/app/tailwind.config.js

content: [
  './projects/app/src/**/**.ts'
]

rather than

content: [
  './src/**/**.ts'
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Configuration - Tailwind CSS
Using relative paths. By default Tailwind resolves non-absolute content paths relative to the current working directory, not the tailwind.config.js file.
Read more >
No PostCSS config found - webpack - Stack Overflow
Made a new file in the root directory named postcss.config.js and added. module.exports = {};. Found this on the following post:.
Read more >
Shared Options - Vite
When aliasing to file system paths, always use absolute paths. Relative alias values will be used as-is and will not be resolved into...
Read more >
postcss-loader | webpack - JS.ORG
You can use different postcss.config.js files in different directories. Config lookup starts from path.dirname(file) and walks the file tree upwards until a ...
Read more >
Configuration | Stylelint
stylelintrc file (without extension) can be in JSON or YAML format. You can add a filename extension to help your text editor provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found