9

Spinning up the sanity studio gets me this error. The page spins up just fine in local host. Any help fixing this would be greatly appreciatedenter image description here

here is the error in full:

[plugin:vite:css] [postcss] Cannot read properties of undefined (reading 'config')
    at getTailwindConfig (/Users/adamsmith/Desktop/codingprojects/portfolio/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:84:63)
    at /Users/adamsmith/Desktop/codingprojects/portfolio/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:96:92
    at /Users/adamsmith/Desktop/codingprojects/portfolio/node_modules/tailwindcss/lib/processTailwindFeatures.js:46:11
    at plugins (/Users/adamsmith/Desktop/codingprojects/portfolio/node_modules/tailwindcss/lib/index.js:38:63)
    at LazyResult.runOnRoot (/Users/adamsmith/Desktop/codingprojects/portfolio/portfolio-build/node_modules/postcss/lib/lazy-result.js:339:16)
    at LazyResult.runAsync (/Users/adamsmith/Desktop/codingprojects/portfolio/portfolio-build/node_modules/postcss/lib/lazy-result.js:393:26)
    at LazyResult.async (/Users/adamsmith/Desktop/codingprojects/portfolio/portfolio-build/node_modules/postcss/lib/lazy-result.js:221:30)
    at LazyResult.then (/Users/adamsmith/Desktop/codingprojects/portfolio/portfolio-build/node_modules/postcss/lib/lazy-result.js:206:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5

This is the contents of my tailwind.config.js file

@type {import('tailwindcss').Config} 
module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [
    require('tailwind-scrollbar')
  ],
}
toadlyfe
  • 411
  • 1
  • 3
  • 7

10 Answers10

29

I ended up creating a tailwind.config.js file in the sanity folder with the following information. It fixed it.

module.exports = {
  content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx}',
],
  theme: {
    extend: {},
  },
  plugins: [],
}
toadlyfe
  • 411
  • 1
  • 3
  • 7
3

When you create the tailwindcss, Ensure that the content array is not empty, do add the following:

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx}',

  ],

  theme: {
    extend: {},
  },
  plugins: [],
}
3

In my case create tailwind.config.js file in the sanity folder and add the code below in that created file

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx}',

  ],

  theme: {
    extend: {},
  },
  plugins: [],
}
3

After moving the tailwind.config.js file into the Sanity folder, Sanity worked, but the front end caused the error. To make it work have two copies of the tailwind CSS file one for the root directory and one inside the Sanity folder.

2

The solution I came to was to make a postcss.config.js and a tailwind.config.js file within the sanity folder. Many of the solutions only mention one which can sometimes solve your issue, though I found this to be a better solution. Try this then npm run dev or sanity start while in the sanity folder.

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './src/**/*.{js,ts,jsx,tsx}',
    './app/**/*.{js,ts,jsx,tsx}',
    './pages/**/*.{js,ts,jsx,tsx}',
    './components/**/*.{js,ts,jsx,tsx}',
  ],
  theme: {
    extend: {},
  },
  plugins: [require('tailwind-scrollbar')({ nocompatible: true })],
};

postcss.config.js

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};
cconsta1
  • 737
  • 1
  • 6
  • 20
1

I had the same error, changing tailwind.config.js file location to under the "sanity-backend" folder, fixed an error for me.

Chris
  • 11
  • 2
0

try to run with sanity dev instead of sanity start. If it doesn't work create tailwind.config.js in sanity-folder and add the following code

module.exports = {
    content:[
        './pages/**/*.{js,ts,jsx,tsx}','./components/**/*.{js,ts,jsx,tsx}','./app/**/*.{js,ts,jsx,tsx}',
    ],
    theme: {
        extend: {},
    },
    plugins: [],
}
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Joker38
  • 7
  • 5
0

Create a postcss.config.js file in the sanity folder and add

module.exports = {}
Moritz Ringler
  • 9,772
  • 9
  • 21
  • 34
0

just create a "postcss.config.cjs" file and add module.exports = {}; this should fix your problem.

enter image description here

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
0

in the case of Linux operating systems create a file with .cjs which says common js file. postcss.config.cjs and add module.exports={}