简体   繁体   English

如何将ReactJS应用程序嵌入到SharePoint插件中

[英]How to embed ReactJS app into SharePoint add-in

I'm really new to SharePoint add-ins and ReactJS, but I'm trying to make these two guys work together. 我真的是SharePoint加载项和ReactJS的新手,但我正在努力使这两个家伙一起工作。 What I have now is my ReactJS app and an empty SharePoint-hosted app as a standalone projects. 我现在拥有的是我的ReactJS应用程序和一个作为独立项目的空SharePoint托管应用程序。

I followed this article and everything seemed to work fine until I decided to try something more complex (using react-route, redux, etc.). 我遵循了这篇文章 ,在我决定尝试更复杂的东西(使用react-route,redux等)之前,一切似乎都工作正常。 Then it stopped working (SharePoint just shows up nothing and there're no errors in devTool). 然后它停止工作(SharePoint仅显示任何内容,并且在devTool中没有错误)。

I guess that the problem is that I don't have react-router, redux, etc. dependencies present on my SharePoint site when deploying my app. 我想问题是在部署应用程序时,我的SharePoint网站上没有React-router,redux等依赖项。 And the question is how do I add all my dependencies (and should I?) to the bundle.js file (generated by webpack) so that I could just copy this bundle.js to SharePoint app and get it working? 问题是我如何将我的所有依赖项(应该吗?)添加到bundle.js文件(由webpack生成)中,这样我就可以将此bundle.js复制到SharePoint应用程序并使其正常工作? Or are there any other ways to do this? 还是有其他方法可以做到这一点?

PS Here's my webpack-config.js PS这是我的webpack-config.js

module.exports = {
devtool: 'source-map',
entry: "./app.js",
mode: "development",
output: {
    filename: "./app-bundle.js"
},
module: {
    rules: [
        {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
                loader: 'babel-loader',
                options: {
                    presets: ['env', 'react']
                }
            }
        },
        {
            test: /\.css$/,
            loader: 'style-loader!css-loader'
        }
    ]
}

} }

Please let me know if you need some additional info regarding project structure, configuration, etc. 如果您需要有关项目结构,配置等的其他信息,请告诉我。

Thanks! 谢谢!

Use Content editor and paste all the html element inside it. 使用内容编辑器并将所有html元素粘贴到其中。 Then save the page and publish 然后保存页面并发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM