The approach I’ve taken can be found within this repository: GitHub - neo4j-contrib/discourse-theme-neo4j · GitHub
The essential points related to Tailwind:
- A separate NPM target builds tailwind using postcss:
"tailwind:dev": "postcss tailwind/global.scss -o assets/tailwind.css - The CSS output is placed in
assetsto be included with the theme. Notice thatabout.jsonincludes the asset location. - The Discourse SCSS does not directly reference this produced CSS
- Instead, there is a javascript initialiser at
javascripts/discourse/initializers/tailwind-init.js.es6which appends the asset to the end of thediscourse-assets-stylesheetselement as a newlinkelement - Important: the Tailwind preflight is disabled in the
tailwind.config.js, because it would otherwise reset all preceding CSS. Instead, I want to add the Tailwind classes and rely on Discourse’s own preflight.
Not elegant, but it works for us. Use for your own inspiration. ![]()
Best,
Andreas