手动迁移
This manual migration process should be run after the automated migration process, to complete the missing parts, or debug issues in the migration CLI output.
Project setup
package.json
Scoped package names
In Docusaurus 2, we use scoped package names:
docusaurus
→@docusaurus/core
This provides a clear distinction between Docusaurus' official packages and community maintained packages. In another words, all Docusaurus' official packages are namespaced under @docusaurus/
.
Meanwhile, the default doc site functionalities provided by Docusaurus 1 are now provided by @docusaurus/preset-classic
. Therefore, we need to add this dependency as well:
{
dependencies: {
- "docusaurus": "^1.x.x",
+ "@docusaurus/core": "^2.0.0-beta.0",
+ "@docusaurus/preset-classic": "^2.0.0-beta.0",
}
}
Please use the most recent Docusaurus 2 version, which you can check out here (using the latest
tag).
CLI commands
Meanwhile, CLI commands are renamed to docusaurus <command>
(instead of docusaurus-command
).
The "scripts"
section of your package.json
should be updated as follows:
{
"scripts": {
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy"
// ...
}
}
A typical Docusaurus 2 package.json
may look like this:
{
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"serve": "docusaurus serve",
"clear": "docusaurus clear"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-beta.0",
"@docusaurus/preset-classic": "^2.0.0-beta.0",
"clsx": "^1.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"browserslist": {
"production": [">0.5%", "not dead", "not op_mini all"],
"development": ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
}
}
Update references to the build
directory
In Docusaurus 1, all the build artifacts are located within website/build/<PROJECT_NAME>
.
In Docusaurus 2, it is now moved to just website/build
. Make sure that you update your deployment configuration to read the generated files from the correct build
directory.
If you are deploying to GitHub pages, make sure to run yarn deploy
instead of yarn publish-gh-pages
script.
.gitignore
The .gitignore
in your website
should contain:
# dependencies
/node_modules
# production
/build
# generated files
.docusaurus
.cache-loader
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
README
The D1 website may have an existing README file. You can modify it to reflect the D2 changes, or copy the default Docusaurus v2 README.