Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I activate the sourcemap for Vue-Cli 4?

I believed the npm run serve command use the sourcemap by default for the js, but it seems not because I always see vue.runtime.esm.js:619.

I made a vue.config.js file at the root level project.

I try two things:

module.exports = {
    configureWebpack: config => {
          config.devtool = 'source-map'
    }
}

and:

module.exports = {
    configureWebpack: {
        devtool: 'source-map'
    }
}

None of them works. I still stuck with vue.runtime.esm.js:619 which is useless.

Does anyone know how really activate the source-map with vue-cli 4?

like image 315
GBMan Avatar asked Jan 11 '20 10:01

GBMan


People also ask

What is source map vue?

Sentry supports demangling of transpiled, minified, and bundled JavaScript using source maps, which are JSON files that contain information about how to map your deployed code back to its original source(s).

How do you fix vue CLI service is not recognized as an internal or external command operable program or batch file?

To solve the error "'vue-cli-service' is not recognized as an internal or external command, operable program or batch file", install the @vue/cli-service package globally by running npm install -g @vue/cli-service and clear your npm cache.

How do I enable source map in webpack?

In a sense, source maps are the decoder ring to your secret (minified) code. Using Webpack, specifying devtool: "source-map" in your Webpack config will enable source maps, and Webpack will output a sourceMappingURL directive in your final, minified file.

How do you check vue CLI is installed or not?

You can verify that it is properly installed by simply running vue , which should present you with a help message listing all available commands.

What is source-map in Vue config?

"source-map" yields source maps for both scss and typescript. Any insight here? Sorry, something went wrong. @nicooprat Which file? vue.config.js?

Where can I Find my Vue app files?

C:\vhosts\app.devesources\assets\js\views\Home.vue C:\vhosts\app.devesources\assets\js\app.js

How do I generate source maps?

Source maps can be either: If you use Webpack in your project, we recommend generating and uploading your source maps by way of sentry-webpack-plugin. If you use a different tool to generate source maps, you can use sentry-cli to upload them to Sentry.

What is the difference between “eval-source-map” and “source-map”?

"eval-source-map" does not yield maps for either scss or typescript. "source-map" yields source maps for both scss and typescript.


1 Answers

Using the generated vue.config.js from vue-cli v4 (generating a vue 3 project) It provided me this file:

// vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
})

I then modified it to this:

// vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    devtool: 'source-map',
  }
})

Which works enough for me to enable VSCode debugging in Chrome/Electron.

*Edit
The error you are getting may be unrelated to source-maps and related to warnings from vue itself. For example

runtime-core.esm-bundler.js:6584
[Vue warn]: Failed to resolve component: AMadeUpComponentName
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
  at <MyView onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > > 
  at <RouterView> 
  at <App>

Unfortunately this is a limitation of vue. However, improvements have been made between VueJS v2 and v3. Finally, I couldn't find an original source, but I read that improving the warning messages to track down the cause of warnings and errors is a high priority feature.

* Edit 10/12/2022

I had an older project that this answer didn't solve at all. After a yarn upgrade and @vue/cli upgrading, this configuration began working again!

like image 162
Nathan Goings Avatar answered Oct 16 '22 01:10

Nathan Goings