d3-interpolate-path 项目教程
1. 项目的目录结构及介绍
d3-interpolate-path/
├── docs/
├── src/
├── test/
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── index.js
├── package-lock.json
├── package.json
├── rollup.config.js
- docs/: 包含项目文档文件。
- src/: 包含项目的源代码文件。
- test/: 包含项目的测试文件。
- .eslintignore: ESLint 忽略配置文件。
- .eslintrc.js: ESLint 配置文件。
- .gitignore: Git 忽略配置文件。
- .npmignore: NPM 忽略配置文件。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文件。
- index.js: 项目入口文件。
- package-lock.json: NPM 锁定依赖版本文件。
- package.json: 项目配置文件,包含依赖、脚本等信息。
- rollup.config.js: Rollup 打包配置文件。
2. 项目的启动文件介绍
项目的启动文件是 index.js
,它是整个项目的入口点。该文件导出了 interpolatePath
函数,用于在两个路径之间进行平滑插值。
// index.js
import { interpolatePath } from './src/interpolatePath';
export { interpolatePath };
3. 项目的配置文件介绍
package.json
package.json
文件包含了项目的基本信息、依赖、脚本等配置。
{
"name": "d3-interpolate-path",
"version": "2.0.0",
"description": "Interpolates path `d` attribute smoothly when A and B have different number of points.",
"main": "index.js",
"scripts": {
"watch": "rollup -c -w",
"build": "rollup -c"
},
"dependencies": {},
"devDependencies": {
"rollup": "^2.3.4",
"rollup-plugin-terser": "^5.3.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pbeshai/d3-interpolate-path.git"
},
"keywords": [
"d3",
"interpolate",
"path",
"svg"
],
"author": "Peter Beshai",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/pbeshai/d3-interpolate-path/issues"
},
"homepage": "https://github.com/pbeshai/d3-interpolate-path#readme"
}
rollup.config.js
rollup.config.js
文件是 Rollup 的打包配置文件,用于将项目打包成不同格式的输出文件。
// rollup.config.js
import { terser } from 'rollup-plugin-terser';
export default {
input: 'index.js',
output: [
{
file: 'build/d3-interpolate-path.js',
format: 'umd',
name: 'd3',
plugins: [terser()]
},
{
file: 'build/d3-interpolate-path.min.js',
format: 'umd',
name: 'd3',
plugins: [terser()]
}
]
};
通过以上配置,项目可以被正确打包并发布。