Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --base and --mode options (#202)
* Refactor triplicate CLI config application code * Remove unused BuildParams type, rename DevParams to CLIParams * Explicitly name CLI ladle * Update CLI examples in docs * Add --base and --mode options This allows doing `ladle build --base=/my-project/`, for e.g. building Ladle storybooks to GitHub Pages, as well as overriding `--mode`, if needed (see #201).
- Loading branch information
Showing
14 changed files
with
115 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ladle/react": minor | ||
--- | ||
|
||
Add `--base` and `--mode` options à la `vite build` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import debug from "./debug.js"; | ||
import path from "path"; | ||
import loadConfig from "./load-config.js"; | ||
|
||
/** | ||
* @param params {import("../shared/types").CLIParams} | ||
*/ | ||
export default async function applyCLIConfig(params) { | ||
debug(`CLI theme: ${params.theme}`); | ||
debug(`CLI stories: ${params.stories}`); | ||
debug(`CLI port: ${params.port || "undefined"}`); | ||
debug(`CLI out: ${params.outDir || "undefined"}`); | ||
params.config = params.config || ".ladle"; | ||
const configFolder = path.isAbsolute(params.config) | ||
? params.config | ||
: path.join(process.cwd(), params.config); | ||
const config = await loadConfig(configFolder); | ||
config.addons.theme.defaultState = | ||
params.theme || config.addons.theme.defaultState; | ||
config.stories = params.stories || config.stories; | ||
config.viteConfig = params.viteConfig || config.viteConfig; | ||
config.outDir = params.outDir || config.outDir; | ||
config.port = params.port || config.port; | ||
config.previewPort = params.previewPort || config.previewPort; | ||
config.base = params.base || config.base; | ||
config.mode = params.mode || config.mode; | ||
debug(`Final config:\n${JSON.stringify(config, null, " ")}`); | ||
process.env["VITE_PUBLIC_LADLE_THEME"] = config.addons.theme.defaultState; | ||
process.env["VITE_PUBLIC_STORIES"] = config.stories; | ||
return { configFolder, config }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7fcdc97
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ladle – ./
ladle-git-master-miksu.vercel.app
ladle.vercel.app
ladle-miksu.vercel.app
ladle.dev