无法判断Vue项目是否处于调试更多状态或Visual Studio的发布模式

问题描述 投票:0回答:1

我正在使用Visual Studio构建此Vue应用程序,无论构建模式(调试/发布)如何,我仍然在控制台中收到以下消息。

您正在开发模式下运行Vue。确保在部署生产时打开生产模式。在https://vuejs.org/guide/deployment.html上查看更多提示

有没有办法知道我是否真的处于发布模式,或者Vue是否只是在向我发送消息?

我知道通常这意味着JS文件已被缩小,是否有Vue应用程序的情况?

我不确定这是否有帮助,但这是我的packages.json文件

{
  "name": "aspnetcore-vuejs",
  "description": "ASP.NET Core & VueJS Starter project",
  "author": "Mark Pieszak",
  "scripts": {
    "dev": "cross-env ASPNETCORE_ENVIRONMENT=Development NODE_ENV=development dotnet run",
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
    "install": "webpack --config webpack.config.vendor.js"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.4",
    "@fortawesome/free-solid-svg-icons": "^5.3.1",
    "@fortawesome/vue-fontawesome": "^0.1.1",
    "axios": "^0.15.3",
    "bootstrap-vue": "^2.0.0-rc.11",
    "core-js": "^2.4.1",
    "dayjs": "^1.7.5",
    "font-awesome": "^4.6.3",
    "material-design-icons-iconfont": "^3.0.3",
    "vue": "^2.1.8",
    "vue-infinite-loading": "^2.3.3",
    "vue-masked-input": "^0.5.2",
    "vue-router": "^2.1.1",
    "vue-select": "^2.5.0",
    "vue-server-renderer": "^2.1.8",
    "vue-template-compiler": "^2.1.8",
    "vuetify": "^1.2.3",
    "vuex": "^2.1.1",
    "vuex-router-sync": "^4.0.1"
  },
  "devDependencies": {
    "aspnet-webpack": "^2.0.1",
    "babel-core": "^6.21.0",
    "babel-loader": "^6.2.10",
    "babel-plugin-transform-async-to-generator": "^6.22.0",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-stage-2": "^6.18.0",
    "babel-register": "^6.18.0",
    "bootstrap": "^4.1.3",
    "cross-env": "^3.1.3",
    "css-loader": "^0.26.1",
    "event-source-polyfill": "^0.0.7",
    "extract-text-webpack-plugin": "^2.0.0-rc",
    "file-loader": "^0.9.0",
    "jquery": "^2.2.1",
    "node-sass": "^4.1.0",
    "optimize-css-assets-webpack-plugin": "^1.3.1",
    "regenerator-runtime": "^0.12.1",
    "sass-loader": "^4.1.0",
    "style-loader": "^0.13.1",
    "url-loader": "^0.5.7",
    "vue-loader": "^10.0.2",
    "webpack": "^2.2.0",
    "webpack-hot-middleware": "^2.12.2"
  }
}
visual-studio debugging vue.js release
1个回答
0
投票

正如您发布的Vue.js deployment guide建议的那样,请检查您的webpack.config.js并确保在部署应用程序时使用正确的mode目标production环境。

在Webpack 4+中,您可以:

module.exports = {
  mode: 'production'
}

但是在Webpack 3及更早版本中,你需要使用DefinePlugin

var webpack = require('webpack')

module.exports = {
  // ...
  plugins: [
    // ...
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('production')
    })
  ]
}

当你准备好了,你应该只需要运行npm run build来开始捆绑你的模块。


相关和有用的读物​​:

© www.soinside.com 2019 - 2024. All rights reserved.