Skip to content

Tailwind config changes don't get detected when using plugin.withOptions #2436

@benjamindavid

Description

@benjamindavid

Describe the problem:

I'm having an issue where changes don't get detected when I'm making changes to the plugin function part of some plugin in my tailwind config.

I've tracked it down to the point where using plugin.withOptions seems to be the problem.

Is there a way to make Tailwind/webpack detect changes made to the plugin function when using plugin.withOptions?

Link to a minimal reproduction:

When using plugin.withOptions, only changes made to the config function get detected:

//tailwind.config.js
const plugin = require('tailwindcss/plugin')
module.exports = {
    plugins: [
        plugin.withOptions(
            function() {
                return function(pluginApi) {
                    const {addBase} = pluginApi
                    addBase({
                        'body': {
                            backgroundColor: 'green' // Changes made here are not detected
                        },
                    })
                }
            },
            function() {
                return {
                    theme: {
                        colors: {
                            blue: {
                                '500': 'blue', // Changes made here are detected
                            },
                        }
                    }
                }
            }
        )
    ],
}

When using plugin without options, changes made to the plugin and config function get detected:

//tailwind.config.js
const plugin = require('tailwindcss/plugin')
module.exports = {
    plugins: [
        plugin(
            function(pluginApi) {
                const {addBase} = pluginApi

                addBase({
                    'body': {
                        backgroundColor: 'green' // Changes made here are detected
                    },
                })
            },
            function() {
                return {
                    theme: {
                        colors: {
                            blue: {
                                '500': 'blue', // Changes made here are detected
                            },
                        }
                    }
                }
            }
        )
    ],
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions