SharePoint FX如何与Angular集成?

时间:2019-08-27 19:39:46

标签: sharepoint

SharePoint FX如何与Angular集成?我知道它对React有很好的支持,但是想知道Angular 6+的SharePoint Framework的优缺点。

1 个答案:

答案 0 :(得分:0)

允许更新一些文件以供Angular与SharePoint Framework一起使用。

package.json

"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/elements": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@webcomponents/custom-elements": "^1.1.1",
"core-js": "^2.5.7",
"rxjs": "^6.2.0",
"zone.js": "^0.8.26"

tsconfig.json

这是IDE的TypeScript配置文件。打开tsconfig.json文件,在“ compilerOptions ”下添加以下行。

"emitDecoratorMetadata": true,

gulpfile.js

此文件定义了项目的所有任务,例如将TypeScript文件编译为JavaScript,捆绑和缩小JS / CSS文件等。我们需要修改构建过程。打开“ gulpfile.js”文件,并在“ build.initialize”行上方添加以下代码。

const webpack = require('webpack');
const path = require('path');

build.configureWebpack.mergeConfig({
   additionalConfiguration: (generatedConfiguration) => {

      generatedConfiguration.plugins.push(new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)fesm5/, path.join(__dirname, './client')));

      return generatedConfiguration;
   }
});

以下是两个有关在SharePoint框架中使用Angular 6的源代码解决方案,供您参考。

Angular Demo Webpart

Angular Elements in SharePoint Framework