메인 컨텐츠로 이동
버전: 3.2.1

CLI(명령 줄 인터페이스)

도큐사우루스는 여러분의 웹 사이트를 만들고 확인하고 배포할 수 있게 도움을 주는 스크립트 모음을 제공합니다.

웹 사이트를 만들면 소스 안에 패키지 관리자를 호출할 수 있는 도큐사우루스 스크립트가 포함되어 있습니다.

package.json
{
// ...
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids"
}
}

Docusaurus CLI commands

도큐사우루스 CLI 명령과 사용법을 설명합니다.

docusaurus start [siteDir]

Builds and serves a preview of your site locally with Webpack Dev Server.

Options

옵션명기본값설명
--port3000개발 서버에서 사용할 포트를 설정합니다.
--hostlocalhost사용할 호스트를 설정합니다. For example, if you want your server to be accessible externally, you can use --host 0.0.0.0.
--localeSpecify site locale to be used.
--hot-onlyfalse빌드 실패 시 폴백 처리로 페이지 새로고침 없이 빠른 모듈 교체(Hot Module Replacement)를 사용할지 여부를 설정합니다. More information here.
--no-openfalseDo not open the page automatically in the browser.
--configundefinedPath to Docusaurus config file, default to [siteDir]/docusaurus.config.js
--poll [optionalIntervalMs]false변경 상태 체크가 제대로 되지 않을 때 폴백 처리로 라이브 리로드 대신 파일 폴링을 사용하도록 설정할 수 있습니다. More information here.
--no-minifyfalseJS/CSS 번들 최소화 없이 웹 사이트를 빌드할지 여부를 설정합니다.
정보

일부 기능(앵커 링크 같은)은 개발 모드에서는 잘 동작하지 않을 수 있습니다. 하지만 제품 모드에서는 정상적으로 동작합니다.

Development over network

When forwarding port 3000 from a remote server or VM (e.g. GitHub Codespaces), you can run the dev server on 0.0.0.0 to make it listen on the local IP.

npm run start -- --host 0.0.0.0

Enabling HTTPS

인증서를 받는 방법은 여러 가지가 있습니다. We will use mkcert as an example.

  1. Run mkcert localhost to generate localhost.pem + localhost-key.pem

  2. Run mkcert -install to install the cert in your trust store, and restart your browser

  3. HTTPS 환경 변수를 설정하고 도큐사우루스 앱을 실행합니다.

HTTPS=true SSL_CRT_FILE=localhost.pem SSL_KEY_FILE=localhost-key.pem yarn start
  1. Open https://localhost:3000/

docusaurus build [siteDir]

제품 배포를 위해 사이트를 컴파일합니다.

Options

옵션명기본값설명
--devBuilds the website in dev mode, including full React error messages.
--bundle-analyzerfalseAnalyze your bundle with the webpack bundle analyzer.
--out-dirbuild현재 워크스페이스를 기준으로 output 디렉터리의 상대 경로를 설정합니다.
--configundefinedPath to Docusaurus config file, default to [siteDir]/docusaurus.config.js
--localeBuild the site in the specified locale. If not specified, all known locales are built.
--no-minifyfalseJS/CSS 번들 최소화 없이 웹 사이트를 빌드할지 여부를 설정합니다.
정보

For advanced minification of CSS bundle, we use the advanced cssnano preset (along with additional several PostCSS plugins) and level 2 optimization of clean-css. If as a result of this advanced CSS minification you find broken CSS, build your website with the environment variable USE_SIMPLE_CSS_MINIFIER=true to minify CSS with the default cssnano preset. Please fill out an issue if you experience CSS minification bugs.

You can skip the HTML minification with the environment variable SKIP_HTML_MINIFICATION=true.

docusaurus swizzle [themeName] [componentName] [siteDir]

Swizzle a theme component to customize it.

npm run swizzle [themeName] [componentName] [siteDir]

# 예 (현재 디렉터리로 설정한다면 siteDir 옵션은 제외할 수 있습니다)
npm run swizzle @docusaurus/theme-classic Footer -- --eject

The swizzle CLI is interactive and will guide you through the whole swizzle process.

Options

옵션명설명
themeName스위즐할 테마 이름
componentName스위즐할 컴포넌트 이름
--list스위즐링에 사용할 수 있는 컴포넌트 표시
--ejectEject the theme component
--wrapWrap the theme component
--danger안전하지 않은 컴포넌트의 즉각적인 스위즐링 허용
--typescript타입스크립트 변형 컴포넌트 스위즐
--configPath to docusaurus config file, default to [siteDir]/docusaurus.config.js
warning

안전하지 않은 컴포넌트: 내부 리팩토링으로 인해 호환성이 손상되는 변경 위험이 높은 컴포넌트입니다.

docusaurus deploy [siteDir]

Deploys your site with GitHub Pages. Check out the docs on deployment for more details.

Options

옵션명기본값설명
--localeDeploy the site in the specified locale. If not specified, all known locales are deployed.
--out-dirbuild현재 워크스페이스를 기준으로 output 디렉터리의 상대 경로를 설정합니다.
--skip-buildfalse빌드 과정 없이 웹 사이트를 배포합니다. 사용자 지정 배포 스크립트를 사용하는 경우에 유용합니다.
--configundefinedPath to Docusaurus config file, default to [siteDir]/docusaurus.config.js

docusaurus serve [siteDir]

웹 사이트를 로컬에서 서비스합니다.

옵션명기본값설명
--port3000사용할 포트를 설정합니다.
--dirbuild현재 워크스페이스를 기준으로 output 디렉터리이 상대 경로를 설정합니다.
--buildfalse서비스 전에 웹 사이트를 빌드합니다.
--configundefinedPath to Docusaurus config file, default to [siteDir]/docusaurus.config.js
--hostlocalhost사용할 호스트를 설정합니다. For example, if you want your server to be accessible externally, you can use --host 0.0.0.0.
--no-openfalse locally, true in CI서버 경로를 브라우저 창에서 열지 마세요.

docusaurus clear [siteDir]

도큐사우루스에서 만든 애셋, 캐시, 산출물을 삭제합니다.

버그를 발견하고 등록하기 전이나 버전 업그레이드 또는 도큐사우루스 사이트에 문제가 생겼을 때 이 명령을 실행하는 것을 권장합니다.

docusaurus write-translations [siteDir]

번역할 JSON 번역 파일을 만듭니다.

By default, the files are written in website/i18n/<defaultLocale>/....

옵션명기본값설명
--locale<defaultLocale>JSON 파일을 번역할 로케일 디렉터리를 설정합니다.
--overridefalse기존 번역 메시지를 덮어쓸지 여부를 설정합니다.
--configundefinedPath to Docusaurus config file, default to [siteDir]/docusaurus.config.js
--messagePrefix''번역되지 않는 문자열을 강조하기 위해 각 번역 메시지에 접두사를 추가하도록 설정할 수 있습니다.

docusaurus write-heading-ids [siteDir] [files]

Add explicit heading IDs to the Markdown documents of your site.

옵션명기본값설명
files플러그인에서 사용하는 모든 MD 파일제목 ID를 작성할 파일
--maintain-casefalse제목 대소문자 유지, 그렇지 않으면 소문자로 처리.
--overwritefalse기존 제목 ID 덮어쓰기