How to compile custom standalone CLI #12294
-
Question: Can we compile a custom standalone CLI?I'm trying to add an arbitrary npm package to be included in the standalone CLI, such as daisyUI. I wonder if I could:
If so, any pointer about how would I go about doing the above? I see no instructions on how to compile the executable. I see some oxide, cargo/Rust thing, but not sure how to proceed. Any pointers are welcome! (Hope this is not a typical xy problem) Alternative: Extending the CLIMaybe instead of me doing a custom build of the standalone CLI. We could extend it allow it to locate packages installed locally. Why?I'm trying to use daisyUI with the standalone CLI (via tailwindcss-rails) using importmaps (no npm/yarn). When adding // config/tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme')
module.exports = {
content: [
'./public/*.html',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/views/**/*.{erb,haml,html,slim}'
],
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/aspect-ratio'),
require('@tailwindcss/typography'),
require('@tailwindcss/container-queries'),
require('daisyui'), // New line
]
} I get an error when compiling/starting the server: Error: Cannot find module 'tailwindcss/defaultTheme'
Require stack:
- /Users/david/src/repos/tailwind-cli/config/tailwind.config.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1955:46)
at Function.resolve (node:internal/modules/cjs/helpers:108:19)
at _resolve (/snapshot/tailwindcss/node_modules/jiti/dist/jiti.js:1:241025)
at jiti (/snapshot/tailwindcss/node_modules/jiti/dist/jiti.js:1:243309)
at /Users/david/src/repos/tailwind-cli/config/tailwind.config.js:1:97
at jiti (/snapshot/tailwindcss/node_modules/jiti/dist/jiti.js:1:245784)
at /snapshot/tailwindcss/lib/lib/load-config.js:37:30
at loadConfig (/snapshot/tailwindcss/lib/lib/load-config.js:39:6)
at Object.loadConfig (/snapshot/tailwindcss/lib/cli/build/plugin.js:135:49) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/david/src/repos/tailwind-cli/config/tailwind.config.js' ]
} This is because importmaps in Rails is actually ✨ no build ✨. Thus, when the standalone CLI does a I've taken a look at this repo's standalone.js file and I see 2 things:
I've also tried downloading daisyUI locally (via Rails Thus, the solution I think, is to compile a custom standalone CLI that has daisyUI added within it's internal |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I had the same itch, so I wrote a GitHub Actions workflow that will repackage the standalone CLI and bundle daisyUI whenever either of the projects gets a new release. Feel free to use tailwind-cli-extra till we get a better upstream solution. If you would like to compile the CLI yourself, then here are the steps to do so:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @dobicinaitis. Repacking with Nix could be an option. There's currently a standalone Nix package that works well. We could use that as the base to package up |
Beta Was this translation helpful? Give feedback.
-
@dobicinaitis You. Are. Awesome. |
Beta Was this translation helpful? Give feedback.
I had the same itch, so I wrote a GitHub Actions workflow that will repackage the standalone CLI and bundle daisyUI whenever either of the projects gets a new release. Feel free to use tailwind-cli-extra till we get a better upstream solution.
If you would like to compile the CLI yourself, then here are the steps to do so:
tailwindcss
repository and checkout the latest release tagnvm install 16 # switch to the stable engine node ./scripts/swap-engines.js
cd standalone-cli npm install