首页 > 解决方案 > 如何在插件中定义特定版本的 Office.JS

问题描述

我开发了一个已在内部使用了大约一年的 Excel 加载项。最近,即使没有对代码进行任何更改,加载项也停止工作。我认为这与 API 的新版本(1.12)有关,它一定改变了我正在使用的东西。

文档中,我只能找到有关如何使用提供最新版本的 CDN 的说明。如何确定要使用的确切版本?


编辑

根据此处的文档,我正在尝试使用 Webpack 将所有 office.js 文件从node_modulesdist 目录复制。由于以下输出,我可以看到 Webpack 找到了文件:

...
../../../../../../../dist/office/ta-in/outlook_strings.debug.js   15.3 KiB
 [emitted]
...

但是文件没有出现在dist目录中。以下是我的相关导出webpack.config.js

frontConf = {
  entry: [ './src/js/index.js' ],
  output: {
    path: path.join(__dirname, 'dist'),
    publicPath: '/',
    filename: '[name].js'
  },
  target: 'web',
  resolve: {
    extensions: ['.html', '.js']
  },
  node: {
    fs: 'empty',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: "babel-loader",
      },
      {
        // Loads the javacript into html template provided.
        // Entry point is set below in HtmlWebPackPlugin in Plugins
        test: /\.html$/,
        use: [
          {
            loader: "html-loader",
            //options: { minimize: true }
          }
        ]
      },
      {
        test: /\.css$/,
        use: [ 'style-loader', 'css-loader' ]
      },
      {
       test: /\.(png|svg|jpg|gif)$/,
       use: ['file-loader']
      }
    ]
  },

  plugins: [
    new CopyPlugin({
      patterns: [
        {from:'node_modules/@microsoft/office-js/dist', 
        to:'/dist/office'}
      ]
    }),
    new HtmlWebPackPlugin({
      template: "./src/html/index.html",
      filename: "./index.html",
      excludeChunks: [ 'server' ]
    })
  ]
}

关于如何为此配置 Webpack 的任何建议?

标签: webpackoffice-jsoffice-addins

解决方案


推荐阅读