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

Overwrite content options is not working #591

Closed
jheng-jie opened this issue Jan 13, 2023 · 5 comments
Closed

Overwrite content options is not working #591

jheng-jie opened this issue Jan 13, 2023 · 5 comments
Labels
question Further information is requested

Comments

@jheng-jie
Copy link

jheng-jie commented Jan 13, 2023

  • package.json
{
  "devDependencies": {
    "@nuxtjs/tailwindcss": "^6.2.0",
    "nuxt": "3.0.0"
  }
}

i tried various settings. but overriding always doesn't work

  1. nuxt.config.ts

    export default {
      tailwindcss: {
        config: {
          content() {
            return ['./theme1/**/*.vue']
          }
        }
      },
    }

    is not working.

  2. tailwind.config.js

    export default {
      content() {
        return ['./theme1/**/*.vue']
      }
    }

    will throw the error. Cannot restart nuxt: (tailwindConfig.content || []) is not iterable

the following settings are possible. but not formal

  1. nuxt.config.ts

    export default {
      hooks: {
        // is working
        'tailwindcss:config'(config: any) {
          config.content = ['./theme1/**/*.vue']
        },
      },
    }
  2. tailwind.config.js

    export default {
      // is working, purge options have changed in Tailwind CSS v3.0.
      purge: [
        'test/*.vue'
      ]
    }

what i need is overwrite not merge. can anyone help?

@jheng-jie jheng-jie added the question Further information is requested label Jan 13, 2023
Copy link
Collaborator

atinux commented Jan 13, 2023

Why using a function for content?

@jheng-jie
Copy link
Author

@atinux I refer to the document's

config/#merging-strategy

@ineshbose
Copy link
Collaborator

I didn't see an option in the source code of the module for content to be function. Moreover, since there are also usage of JSON.stringify to add templates, the function would get removed (though the module internally copies over the config according to my knowledge). But I've opened #592 as a draft fix for it if Atinux would provide feedback. 🙂

@ineshbose
Copy link
Collaborator

@jheng-jie can you check with 6.3.0?

@atinux atinux closed this as completed Jan 26, 2023
@jheng-jie
Copy link
Author

@ineshbose 6.3.0 is working! thank you very much.

// nuxt.config.ts
{
  tailwindcss: {
    config: {
      content(origin: TailwindConfig['content']) {
        console.log('origin', origin)
        // overwrite
        return [
          './src/App.vue',
          './src/theme/_common/**/*.{vue,scss}',
          `./src/theme/${process.env.VITE_THEME}/**/*.{vue,scss}`,
        ]
      },
    },
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants