如何将不同的清单文件用于开发和生产Excel JS React?

发布于 2025-02-08 13:05:17 字数 942 浏览 1 评论 0原文

我正在尝试开发一个办公室加载项,并成功地将其部署到了Azure。但是,为了测试我的代码的小迭代,我想使用localhost。因此,我想拥有一个开发环境和生产环境。可悲的是,有关如何处理此操作的MS文档相当薄。如何设置项目进行部署和测试? MS文档仅指出,建议维护不同的清单文件: Microsoft清单文档

我已经创建了一个subtest.xml和一个subtest_prod.xml文件,但是我如何配置要采用哪个清单文件的项目?在WebPack.config.js文件中,我可以看到此信息:

const urlDev = "https://localhost:3000/";
const urlProd = "https://localhost:3000/"; // CHANGE THIS TO YOUR PRODUCTION DEPLOYMENT LOCATION

但是应该如何设置项目?因此,我可以选择运行开发(本地服务器)并准备好后,我可以将其部署到Azure?

非常感谢您对此事的建议。

I am trying to develop an office add-in and I succesfully deployed it to Azure. But for testing small iterations of my code I would like to use the localhost. So I would like to have a development environment and a production environment. Sadly the MS documentation on how to handle this is rather thin. How can I setup the project for deployment and testing? the MS documentation only states that it is recommended to maintain different manifest files:
microsoft manifest documentation

I have created a manifest.xml and an manifest_prod.xml file but how can I configure the project which manifest file to take? in the webpack.config.js file I can see this info:

const urlDev = "https://localhost:3000/";
const urlProd = "https://localhost:3000/"; // CHANGE THIS TO YOUR PRODUCTION DEPLOYMENT LOCATION

But how should the project be set up? so I can choose to run the development (local server) and once ready, I can deploy that to Azure?

many thanks for suggestions on the matter.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼中杀气 2025-02-15 13:05:17

如果您使用Yeoman Generator来脚手架Web加载项项目,则使用WebPack来处理此类操作。打开wepblpack.config.js文件,然后在那里找到以下行:

const urlDev = "https://localhost:3000/";
const urlProd = "https://www.contoso.com/"; // CHANGE THIS TO YOUR PRODUCTION DEPLOYMENT LOCATION

因此,您的清单将根据用于构建解决方案的配置进行更新。以下一部分可以解决问题:

new CopyWebpackPlugin({
        patterns: [  
          {
            from: "manifest*.xml",
            to: "[name]" + "[ext]",
            transform(content) {
              if (dev) {
                return content;
              } else {
                return content.toString().replace(new RegExp(urlDev, "g"), urlProd);
              }
            },
          },
        ],
      }),

因此,在发行配置中构建加载项,您将获得正确的清单文件,该文件已复制到生产URL。

尝试使用以下命令,然后查看结果清单文件:

"build": "webpack --mode production",
"build:dev": "webpack --mode development",

In case if you've used the yeoman generator for scaffolding the web add-in project Webpack is used for handling such things. Open the wepblpack.config.js file and find the following lines there:

const urlDev = "https://localhost:3000/";
const urlProd = "https://www.contoso.com/"; // CHANGE THIS TO YOUR PRODUCTION DEPLOYMENT LOCATION

So, your manifest will be updated according to the config used to build the solution. The following part does the trick:

new CopyWebpackPlugin({
        patterns: [  
          {
            from: "manifest*.xml",
            to: "[name]" + "[ext]",
            transform(content) {
              if (dev) {
                return content;
              } else {
                return content.toString().replace(new RegExp(urlDev, "g"), urlProd);
              }
            },
          },
        ],
      }),

So, building the add-in in the release configuration you will get a correct manifest file copied pointing to the production URL.

Try to use the following commands and then check out the result manifest file:

"build": "webpack --mode production",
"build:dev": "webpack --mode development",
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文