Using in OmniWeb
Since we are gradually onboarding the design system in OmniWeb, we use a technique where you have to declare that your package is using the components from the design system. This is will change when we have onboarded a "critical mass" of the OmniWeb-packages 😉
Preparing for production
To use components from the design system, you have to do two things in addition to installing the components. One; enable purging (remove unused CSS in production-builds1) and two; tell OmniWeb to include the TailwindCSS-file for that module.
1) Install the component(s)
Install the component(s) you are going to use along with the
@ntds/core
package, like so:
2) Enable CSS-purging on your package
We need to tell OmniWeb that we are expecting the package of interest to use TailwindCSS util-classes and that the purging-process need to look for usage in certain files.
We do this by adding a tailwind.purge.js
file with the following
content in the root of the OmniWeb-package you want to add support in, like so:
For most packages there should be no need to use any other than
the standard test. This test (as stated in the code-comments over),
are considering every component that starts with a capital letter
and have .js
, .jsx
or .tsx
extension.
Only bundled files gets considered
OmniWeb only pass files to the test
-function that actually are part
of the production build. That is to say, only files that is imported
somewhere in the Webpack dependency tree gets considered. This prevents
tests, jumpstart-files and any other support-files to affecting what
util-classes gets purged or not.
Not active in development
It's worth mentioning that when you start OmniWeb in development-mode
using yarn dev
, no purging will be performed. Purging is only used
to optimize for production.
In development ALL Tailwind-classes are included in the CSS.
Debugging the purging-process
To see what files are being used and ignored in the purging-process,
enable the DEBUG
flag ntds:tailwind-purge-plugin
before you run
yarn build
, like so:
Example output:
⦿ match
→ the file was included and the purge-process will look for TailwindUtil-classes𝗑 miss
→ the file was ignored
Whether we get a miss or a match, is the result of the test
in the
tailwind.purge.js
-files returns true
or false
.
3) Tell OmniWeb to include the CSS-file
Lastly (and temporarily) wee need ensure that the TailwindCSS-file gets
severed alongside the package when needed. Include the following import
in the root-point of your package, typically the Routes
-file.
Using with jumpstart
Jumpstart have built-in support for the TailwindCSS-configuration of the design system and does require any further steps (just make sure that you are using the latest version).
How to update jumpstart
You can update jumpstart to the latest version running this command:
When you start jumpstart your component, it can be a good idea to
reset the jumpstart-cache by using the --clear-cache
flag:
This will make sure that you get the latest CSS generated from the
latest @ntds/core
Tailwind-configuration.