SharepointPlus 项目教程
1. 项目目录结构及介绍
SharepointPlus/
├── browser/
│ └── sharepointplus.js
├── dist/
│ └── sharepointplus.min.js
├── docs/
│ └── ...
├── lib/
│ └── ...
├── src/
│ └── ...
├── test/
│ └── ...
├── .gitignore
├── .npmignore
├── LICENSE
├── package.json
├── README.md
└── webpack.config.js
目录结构介绍
- browser/: 包含用于浏览器环境的 SharepointPlus 库文件。
- dist/: 包含压缩后的 SharepointPlus 库文件。
- docs/: 包含项目的文档文件。
- lib/: 包含项目的主要源代码文件。
- src/: 包含项目的源代码文件。
- test/: 包含项目的测试文件。
- .gitignore: Git 忽略文件配置。
- .npmignore: npm 忽略文件配置。
- LICENSE: 项目许可证文件。
- package.json: 项目的 npm 配置文件。
- README.md: 项目的介绍和使用说明文件。
- webpack.config.js: 项目的 Webpack 配置文件。
2. 项目启动文件介绍
SharepointPlus 项目的主要启动文件是 browser/sharepointplus.js
。这个文件是用于浏览器环境的 SharepointPlus 库文件,可以直接在 HTML 文件中引入使用。
<script type="text/javascript" src="path/to/sharepointplus.js"></script>
在 Node.js 环境中,可以通过 npm 安装并引入:
npm install sharepointplus
import $SP from 'sharepointplus';
3. 项目的配置文件介绍
package.json
package.json
是项目的 npm 配置文件,包含了项目的基本信息、依赖项、脚本命令等。
{
"name": "sharepointplus",
"version": "6.2.0",
"description": "SharepointPlus ($SP) is a JavaScript library which offers some extended features for SharePoint entirely on client side (requires no server install)",
"main": "lib/sharepointplus.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"sharepoint",
"javascript",
"library"
],
"author": "Aymkdn",
"license": "LGPL-3.0",
"dependencies": {
"node-sp-auth": "^3.0.6"
}
}
webpack.config.js
webpack.config.js
是项目的 Webpack 配置文件,用于打包和构建项目。
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'sharepointplus.min.js',
path: path.resolve(__dirname, 'dist')
},
mode: 'production'
};
这个配置文件定义了入口文件 src/index.js
,输出文件 dist/sharepointplus.min.js
,以及构建模式为 production
。