Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass THEME_KEY parameter to CLI dev script #54

Open
stewcam opened this issue Jan 9, 2024 · 4 comments
Open

How to pass THEME_KEY parameter to CLI dev script #54

stewcam opened this issue Jan 9, 2024 · 4 comments

Comments

@stewcam
Copy link

stewcam commented Jan 9, 2024

I could not work out the correct syntax for adding the THEME_KEY parameter to npm dev or npx astro dev scripts (as suggested in the features list). I tried a few conventional ways including:
npm run dev -- THEME_KEY=indigone
npm run dev -- --THEME_KEY=indigone
I was able to make the change by direct edit of the default section of tailwind.theme.config.cjs but how does it work through CLI?

@one-aalam
Copy link
Owner

Hey @camedgell the THEME_KEY needs to go before the command you wanna run. You can pass THEME_KEY with the dev or build commands like THEME_KEY=purpleheart astro build/dev to change the color theme being used.

@stewcam
Copy link
Author

stewcam commented Jan 15, 2024

Thanks but the suggested syntax does not work at my end (running on Windows 11). Error code is EINVALIDTAGNAME with error message Invalid tag name "THEME_KEY=purpleheart" of package "THEME_KEY=purpleheart": Tags may not have any characters that encodeURIComponent encodes.

@lovettbarron
Copy link

You should be able to pass it direct in the package.json

eg.

  "scripts": {
    "dev": "THEME_KEY=indigone astro dev",
    "build": "astro build",
    "check": "astro check",
    "postbuild": "node ./scripts/search/prepare-index.js",
    "preview": "astro preview",
    "check:type": "tsc --project tsconfig.json --pretty --noEmit",
    "lint": "biome lint src",
    "format": "biome format src --write",
    "cz": "cz"
  },

@stewcam
Copy link
Author

stewcam commented Jan 17, 2024

Thanks @lovettbarron but that does not work either. However, I have found that I can change the theme by direct edit of the default section of tailwind.theme.config.cjs, so will proceed with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants