如何在 vue.js 应用程序的生产中禁用源映射? [英] How can I disable source maps in production for a vue.js app?

查看:50
本文介绍了如何在 vue.js 应用程序的生产中禁用源映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是使用 vue cli 创建的.我找不到在生产中禁用源映射的任何选项.我的 package.json 中的 npm build 步骤如下所示:

My app is created with the vue cli. I can't find any option to disable source maps in production. The npm build step in my package.json looks like this:

"build": "vue-cli-service build",

在 angular 中,我可以将 --prod 添加到我的构建步骤中以使其工作.vue.js 有没有这样的选项?或者我是否必须更改 webpack 配置(由 cli 隐藏)?

In angular, i can just add --prod to my build step to make it work. Is there any such option for vue.js? Or do I have to change the webpack config (which is hidden by the cli)?

推荐答案

您可以使用项目根目录中的 vue.config.js 文件对内部 webpack 配置进行更改(您可能需要创建手动).

You make changes to the internal webpack config with the vue.config.js file at the project root (you may need to create it manually).

有一个 productionSourceMap 选项,因此您可以禁用源为生产而构建时的地图:

There is a productionSourceMap option so you can disable source maps when building for production:

module.exports = {
  productionSourceMap: false
};

这篇关于如何在 vue.js 应用程序的生产中禁用源映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆