echarts 文档离线部署
方法一
不用构建最简单方法
1
| git clone https://gitee.com/cxvh/echarts-website.git
|
- 批量替换
https://echarts.apache.org/
为http://localhost:3000/
- 复制粘贴文件
echarts-website/zh/asset
—> echarts-website/asset
echarts-website/zh/css
—> echarts-website/asset
echarts-website/zh/dist
—> echarts-website/asset
echarts-website/zh/images
—> echarts-website/asset
echarts-website/zh/js
—> echarts-website/asset
1 2 3
| npm install --global serve cd echarts-website serve -p 3000
|
方法二
拉源码手动构建
环境准备
准备Ubuntu
环境
Ubuntu
环境准备
切换root
账号->su root
安装git
,(拉取代码用)
安装n(node
版本管理工具)
验证环境安装OK
安装node
n install 20
n install 18
n install 16
拉取代码
echarts
的git
仓库,全部复制粘贴到命令行
1 2 3 4 5 6 7 8
| cd ~ mkdir echarts && cd echarts git clone https://gitee.com/cxvh/echarts-website.git git clone https://gitee.com/cxvh/echarts-www.git git clone https://gitee.com/cxvh/echarts-examples.git git clone https://gitee.com/cxvh/echarts-doc.git git clone https://gitee.com/cxvh/echarts-theme-builder.git git clone https://gitee.com/cxvh/echarts-handbook.git
|
构建
检查网络是否能打开 github.com
如果npm i
失败,多尝试几次
echarts-www 1
环境 node20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| const path = require('path'); const config = require('./common');
config.host = 'http://localhost:3000';
config.cdnPayRootMap = { zh: config.host, en: 'http://localhost:3000' }; config.cdnFreeRootMap = { zh: config.host, en: config.host };
config.galleryPath = 'http://localhost:3000/examples/'; config.releaseDestDir = path.resolve(__dirname, '../../echarts-website');
module.exports = config;
|
1 2 3 4
| cd ~/echarts/echarts-www npm i
node ./bin/build.js --env localsite --clean
|
echarts-theme-builder
环境 node17
- 切换
node
版本,输入n
,按上下选择17
,按enter
选中切换
1 2 3
| cd ~/echarts/echarts-theme-builder npm i npm run release
|
echarts-doc
环境 node16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| const path = require('path');
module.exports = { galleryViewPath: 'http://localhost/echarts-website/examples/${lang}/view.html?c=', galleryEditorPath: 'http://localhost/echarts-website/examples/${lang}/editor.html?c=', handbookPath: 'http://localhost/echarts-website/handbook/${lang}/', websitePath: './',
imagePath: 'asset/img/', gl: { imagePath: 'asset/gl/img/' },
releaseDestDir: path.resolve(__dirname, '../../echarts-website'), ecWWWGeneratedDir: path.resolve(__dirname, '../../echarts-www/_generated') };
|
- 修改替换
js
函数~/echarts/echarts-doc/build.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| function copySite() {
for (let lang of languages) { const jsSrcPath = path.resolve(projectDir, `public/${lang}/js/doc-bundle.js`); const cssSrcDir = path.resolve(projectDir, `public/${lang}/css`); const jsDestPath = path.resolve(config.releaseDestDir, `${lang}/js/doc-bundle.js`); fse.copySync(jsSrcPath, jsDestPath); console.log(chalk.green(`js copied to: ${jsDestPath}`));
const cssDestDir = path.resolve(config.releaseDestDir, `${lang}/css`); fse.copySync(cssSrcDir, cssDestDir); console.log(chalk.green(`css copied to: ${cssDestDir}`)); }
console.log('Copy site done.'); }
|
- 修改文件
~/echarts/echarts-doc/package.json
1 2 3 4 5
| cross-env NODE_OPTIONS=--openssl-legacy-provider
改为
cross-env
|
1 2 3 4
| cd ~/echarts/echarts-doc npm i npm run build:site npm run localsite
|
echarts-examples
环境 node16
1 2 3 4 5
| return './editor.html?' + hash.join('&');
return './zh/editor.html?' + hash.join('&');
|
- 修改文件
~/echarts/echarts-examples/package.json
1 2 3 4 5
| cross-env NODE_OPTIONS=--openssl-legacy-provider
cross-env
|
- 修改替换文件
~/echarts/echarts-examples/build/minify-loader.js
1 2 3 4
| module.exports = function minifyLoader(source, map, meta) { return source; };
|
1 2 3 4
| cd ~/echarts/echarts-examples npm i npm run localsite npm run release
|
echarts-www 2
环境 node20
- 切换
node
版本,输入n
,按上下选择20
,按enter
选中切换
1 2 3 4
| cd ~/echarts/echarts-www/bin node ./releasePages.js cd ~/echarts/echarts-www node bin/build.js --env localsite
|
echarts-handbook
环境 node16
1 2 3 4 5 6 7 8 9 10 11
| export default { routerBase: '/handbook', rootPath: 'http://localhost:3000/handbook', exampleViewPath: 'http://localhost:3000/examples/${lang}/view.html?c=', exampleEditorPath: 'http://localhost:3000/examples/${lang}/editor.html?c=', mainSitePath: 'http://localhost:3000/', optionPath: 'http://localhost:3000/option.html#', gitRepo: 'apache/echarts-handbook' }
|
- 修改替换
js
函数~/echarts/echarts-handbook/build/generate-contributors.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| async function ghWeb() { const GH_CONTRIBUTOR_URL = 'https://github.com/apache/echarts-handbook/contributors/master/' const GH_CONTRIBUTOR_LIST_URL = 'https://github.com/apache/echarts-handbook/contributors-list/master/' const total = paths.length const tasks = new Array(total) for (let i = 0; i < total; ++i) { ((i) => { const path = paths[i].slice(2) })(i) } const results = await Promise.allSettled(tasks) const errorCount = results.filter(r => r.status === 'rejected').length console.log(` All Done! ${total} Total, ${total - errorCount} Successful, ${errorCount} Errors` ) console.log('\nResults', entries) Object.keys(entries).length && writeToFile() }
|
- 修改文件
~/echarts/echarts-handbook/package.json
1 2 3 4 5
| cross-env NODE_OPTIONS=--openssl-legacy-provider
改为
cross-env
|
1 2 3 4 5 6 7
| cd ~/echarts/echarts-handbook npm i rm -rf dist rm -rf .nuxt npm run build:localsite rm -rf ../echarts-www/handbook cp -R ./dist ../echarts-www/handbook
|
echarts-website
cd ~/echarts/echarts-website
- 复制粘贴文件
./zh/asset
—> ./asset
./zh/css
—> ./asset
./zh/dist
—> ./asset
./zh/images
—> ./asset
./zh/js
—> ./asset
1 2
| npm i serve -g serve ~/echarts/echarts-website -p 3000
|