-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(v2): allow custom output directory for build #2417
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 18e92ec |
Thanks for the PR. Did you see #2410 before creating this? |
I didn't! I started working on this a few days ago and didn't check the issues. I saw this issue from a while back and thought I'd take a crack at it. |
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.
Little improvements.
export async function deploy(siteDir: string): Promise<void> { | ||
export async function deploy( | ||
siteDir: string, | ||
cliOptions: Partial<BuildCLIOptions>, |
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.
cliOptions: Partial<BuildCLIOptions>, | |
cliOptions: Partial<BuildCLIOptions> = {}, |
website/docs/cli.md
Outdated
@@ -59,6 +59,7 @@ Compiles your site for production. | |||
| Options | Default | Description | | |||
| --- | --- | --- | | |||
| `--bundle-analyzer` | | Analyze your bundle with [bundle analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) | | |||
| `--outDir` | build | The full path for the new output directory, relative to the current workspace. | |
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.
| `--outDir` | build | The full path for the new output directory, relative to the current workspace. | | |
| `--outDir` | `build` | The full path for the new output directory, relative to the current workspace. | |
website/docs/cli.md
Outdated
|
||
| Options | Default | Description | | ||
| --- | --- | --- | | ||
| `--outDir` | build | The full path for the new output directory, relative to the current workspace. | |
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.
| `--outDir` | build | The full path for the new output directory, relative to the current workspace. | | |
| `--outDir` | `build` | The full path for the new output directory, relative to the current workspace. | |
.action((siteDir = '.', {bundleAnalyzer}) => { | ||
.option( | ||
'--outDir <outDir>', | ||
'The full path for the new output directory, relative to the current workspace.', |
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.
'The full path for the new output directory, relative to the current workspace.', | |
'The full path for the new output directory, relative to the current workspace (default = build).', |
wrapCommand(deploy)(path.resolve(siteDir)); | ||
.option( | ||
'--outDir <outDir>', | ||
'The full path for the new output directory, relative to the current workspace.', |
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.
'The full path for the new output directory, relative to the current workspace.', | |
'The full path for the new output directory, relative to the current workspace (default = build).', |
Updated! |
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.
Thanks for this PR. I was thinking of just adding it to docusaurus.config.js
. Was there any particular reasoning to add this option to the CLI command?
@yangshun Partly due to the talk in this issue. That was back in V1 so thoughts might have changed on that. Also, keeping the siteDir and outDir options next to each other made sense to me and having both the paths relative to some workspace root. |
@lex111 what do you think? Should it be in the config or as a CLI option? Next.js puts it in the config while Gatsby added it then reverted it and now still don't have it (gatsbyjs/gatsby#1878). |
I actually prefer to have this feature as a option to the CLI command.
Current implementation is fine with me.
ср, 18 мар. 2020 г. в 18:03, Yangshun Tay <[email protected]>:
… @lex111 <https://github.com/lex111> what do you think? Should it be in
the config or as a CLI option? Next.js puts it in the config
<https://nextjs.org/docs/api-reference/next.config.js/setting-a-custom-build-directory>
while Gatsby added it then reverted it and now still don't have it (
gatsbyjs/gatsby#1878 <https://github.com/gatsbyjs/gatsby/issues/1878>).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2417 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBUIO37MP4OCWPWM5ZGM33RIDPEBANCNFSM4LLX5KFA>
.
|
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.
Thank you!
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.
Sorry can we do --out-dir
instead to have consistent naming with our other CLI options?
Lemme know if you're not available to do it, I should be able to take it over and do the rename.
@yangshun Updated! |
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.
Awesome, thank you!
Motivation
Resolves #2410
Docusaurus 2 added the ability to specify a
siteDir
, so it would be nice if the output directory of the build could be changed as well. I have been working in an nx workspace, and all builds end up indist
at the root with my docs website atapps/website
. Currently, there is no way to place the build anywhere except for inside thesiteDir
.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
I tested all these changes by running
npx @docusaurus/init@next init
to create a new repo. I built the packages and copied them over to the new repo.Ran
yarn build
to verify normal behaviorRan
yarn build --outDir build/nested
to verify custom output directoryCreated a nested version by copying all docusaurus related content into a nested folder called
nested
Ran
yarn build nested
to verify normal behaviorRan
yarn build nested --outDir
to verify custom output directoryCreated a github repo to test deploy.
Tested the commands above with deploy (Nested project has some tweaks to the docs so as to ensure I could see the difference).
Related PRs
None