【问题标题】:Enable sourcemaps in Vue-Vite在 Vue-Vite 中启用源映射
【发布时间】:2021-05-22 07:16:35
【问题描述】:

是否可以在生产环境中启用 Vue-Vite 中的 sourcemaps?

我想将它用于 Bugsnag。

在文档中找不到任何关于它的信息。

In dev it just works out of the box.

【问题讨论】:

    标签: vue.js vuejs3 bugsnag vite


    【解决方案1】:

    感谢@tony19 我可以找到它:

    从 vue ~2.0 开始,它的工作方式如下:

    <projectRoot>/vite.config.js:

    /**
    * @type {import('vite').UserConfig}
    */
    export default {
        plugins: [vue()],
        build: {
            sourcemap: true,
        },
    }
    

    【讨论】:

      【解决方案2】:

      Vite 2.x (docs):

      // vite.config.js
      export default {
        build: {
          sourcemap: true,
        },
      }
      

      Vite 1.x:

      // vite.config.js
      export default {
        sourcemap: true,
      }
      

      【讨论】:

        【解决方案3】:

        正如其他答案中提到的,必须启用build.sourcemap 设置才能生成源映射:

        export default {
          build: {
            sourcemap: true,
          },
        }
        

        如果您正在寻找与 Bugsnag 的简单集成,请查看以下库:

        https://github.com/ElMassimo/vite-plugin-bugsnag

        它提供了一个插件来上传源地图,并为您启用build.sourcemap 设置。

        【讨论】:

          猜你喜欢
          • 2022-07-29
          • 2019-12-20
          • 2013-06-21
          • 1970-01-01
          • 2014-06-14
          • 1970-01-01
          • 1970-01-01
          • 2020-08-11
          相关资源
          最近更新 更多