For 1 and 2 it looks like your component library could export a Tailwind plugin that a consuming project would register in their own Tailwind config.
The second argument to plugin() can be any configuration your component libary wants to merge with the user's Tailconfig config.
E.g.
// plugin.js
const plugin = require('tailwindcss/plugin')
const myComponentLibraryConfig = {
theme: {
extend: {
colors: {
salmon: 'salmon'
}
}
}
}
module.exports = plugin(({ addUtilities, addComponents, e, config }) => {
// Add your custom styles here
}, myComponentLibraryConfig),
When publishing your component library as a package, ensure the plugin is included.
Then, in your consuming project:
// tailwind.config.js
module.exports = {
//...
plugins: [
require('my-component-library/plugin')
]
}
For 3, it looks like you might need to explicitly add the location of your component library's components to the content section. E.g.
// tailwind.config.js
module.exports = {
content: [
"./node_modules/my-component-library/**/*.js",
"./src/components/**/*.{js,jsx,ts,tsx}", // or whatever
]
}
The actual paths to things will depend on your project strucutures, but hopefully you get the idea.