TSDX with TailwindCSS PostCSS plugin -- inject
and purge
options
#947
-
I'm new to tsdx and I'm having trouble setting up TailwindCSS. I've created a const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const tailwindcss = require('tailwindcss');
module.exports = {
rollup(config, options) {
config.plugins.push(
postcss({
plugins: [
tailwindcss({
purge: ['./src/**/*.tsx'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}),
autoprefixer(),
],
inject: false,
// only write out CSS for the first bundle (avoids pointless extra files):
extract: !!options.writeMeta,
})
);
return config;
},
}; I then import my
TSDX then actually does build the CSS file and outputs it correctly at
Any tips on getting this to work? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Looks like the problem was with: Purging can be fixed by changing the build command to |
Beta Was this translation helpful? Give feedback.
-
Update: In addition to changing @creativiii - am I correct that once you modify the const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const tailwindcss = require('tailwindcss');
module.exports = {
rollup(config, options) {
config.plugins.push(
postcss({
plugins: [
tailwindcss({
purge: ['./src/**/*.tsx'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}),
autoprefixer(),
],
- inject: false,
+ inject: true,
// only write out CSS for the first bundle (avoids pointless extra files):
extract: !!options.writeMeta,
})
);
return config;
},
}; |
Beta Was this translation helpful? Give feedback.
-
Is there anyway to add TailwindCSS to example? I just want to use tailwind on example, not the actually library. Thanks |
Beta Was this translation helpful? Give feedback.
Looks like the problem was with:
inject
. I switched it toinject: true,
and css is working.Purging can be fixed by changing the build command to
"build": "NODE_ENV=production tsdx build",
.