Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue-cli project source map not working/how to get working

I created a new project using vue-cli(@vue/cli 4.3.1). When there is an error in one of my component files(.vue file), in chrome console i do not see the actual file/line number. Instead i see a file reference called vue.runtime.esm.js?2b0e:619. Did some googling on how to enable source map. I added a vue.config.js file on my project root and added below lines:

module.exports = {
   configureWebpack: (config) => {
       config.devtool = 'eval-source-map'
   },
   productionSourceMap: true
};

Did npm run server. But still i do not see the actual file reference.

How do i enable source map in a vue-cli-project??

\\File: packages.json
{
  "name": "real-world-vue",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build --mode development",
    "lint": "vue-cli-service lint",
    "build-watch": "vue-cli-service build-watch --mode development"
  },
  "dependencies": {
    "axios": "^0.19.2",
    "core-js": "^3.6.4",
    "json-server": "^0.16.1",
    "vue": "^2.6.11",
    "vue-router": "^3.1.6",
    "vuejs-datepicker": "^1.6.2",
    "vuex": "^3.1.3"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-plugin-eslint": "~4.3.0",
    "@vue/cli-plugin-router": "~4.3.0",
    "@vue/cli-plugin-vuex": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.1.1",
    "eslint-plugin-vue": "^6.2.2",
    "node-sass": "^4.14.0",
    "prettier": "^1.19.1",
    "sass-loader": "^8.0.2",
    "vue-cli-plugin-build-watch": "~1.0.0",
    "vue-template-compiler": "^2.6.11"
  }
}

Please help.
like image 869
Yeasir Arafat Majumder Avatar asked May 09 '26 10:05

Yeasir Arafat Majumder


1 Answers

In my case I got it to work using devtool right under configureWebpack, so no config field there.

I also had to use 'cheap-module-source-map' instead of 'eval-source-map'. In the end it would look like this:

module.exports = {
  configureWebpack: {
    devtool: "cheap-module-source-map",
  },
   productionSourceMap: true
};
like image 83
Vinicius Bazanella Avatar answered May 14 '26 00:05

Vinicius Bazanella



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!