<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Valentin</title>
    <description>The latest articles on Forem by Valentin (@valentin9).</description>
    <link>https://forem.com/valentin9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F156971%2F9379905e-927a-41b8-8a6d-9c0ca21023a0.jpg</url>
      <title>Forem: Valentin</title>
      <link>https://forem.com/valentin9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/valentin9"/>
    <language>en</language>
    <item>
      <title>Force enable Vue.js devtools in production mode.</title>
      <dc:creator>Valentin</dc:creator>
      <pubDate>Wed, 26 Aug 2020 14:12:02 +0000</pubDate>
      <link>https://forem.com/valentin9/force-enable-vue-js-devtools-in-production-mode-49jg</link>
      <guid>https://forem.com/valentin9/force-enable-vue-js-devtools-in-production-mode-49jg</guid>
      <description>&lt;p&gt;&lt;strong&gt;TLDR update:&lt;/strong&gt;&lt;br&gt;
as &lt;a class="mentioned-user" href="https://dev.to/hzmming"&gt;@hzmming&lt;/a&gt; mentioned in comments - there is now a chrome extension "&lt;a href="https://chrome.google.com/webstore/detail/vue-force-dev/oohfffedbkbjnbpbbedapppafmlnccmb" rel="noopener noreferrer"&gt;Vue force dev&lt;/a&gt;" you can use to automate what I described here.&lt;/p&gt;




&lt;p&gt;Every once in a while we need to debug something in production. But with Vue.js deployed with devtools disabled, you'll see the message:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foaxr31jtai30gq2e7z60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foaxr31jtai30gq2e7z60.png" alt="Devtools inspection is not available because it's in production mode or explicitly disabled by the author."&gt;&lt;/a&gt;&lt;br&gt;
Now it's a PITA to debug if you can't reproduce the bug on your dev environment.&lt;/p&gt;

&lt;p&gt;But, since "it's just JavaScript" – we can "hack the mainframe" easily. All we have to do is to find where Vue is loaded and overwrite one option:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Vue.config.devtools = true


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Most bundlers leave the comments from a source file for licensing purposes, so we can search all files for a specific comment: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

 * Vue.js v2.6.11
 * (c) 2014-2019 Evan You
 * Released under the MIT License.
 */


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To search through all sources in chrome devtools click on the dots and select &lt;code&gt;search&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft3wcnvw4nswlb4b07spo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft3wcnvw4nswlb4b07spo.png" alt="chrome devtools search option"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No need to copy the exact version, simply searching for "Vue.js" should get you the correct line most of the time. It should look similar to this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqdtwf9cu38o4dew24naa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqdtwf9cu38o4dew24naa.png" alt="Source code with Vue package"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set a breakpoint on this line and reload the page. If it's all minified and in one line, you'll need to jump to the very end of it with the "step over next function call (F10 / CMD ')". If it's not minified you'll need to set a breakpoint after the whole Vue code block.&lt;/p&gt;

&lt;p&gt;Now by looking through the variables in our scope we need to find the Vue object. With Webpack Vue should be inside exports, something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feyfeufeakppfuxgb3z5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feyfeufeakppfuxgb3z5r.png" alt="Variables in our scope"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our case, we see that the property &lt;code&gt;exports&lt;/code&gt; of the object &lt;code&gt;t&lt;/code&gt; is our Vue object.&lt;/p&gt;

&lt;p&gt;Now go to the console, and overwrite the devtools option with &lt;code&gt;true&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdl3pz5zzp6jugb3e7op0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdl3pz5zzp6jugb3e7op0.png" alt="Setting the devtoops option in console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our breakpoint can be removed and the runtime resumed - that's it! Just close the developer tools and open again to see our Vue tab available to us!&lt;/p&gt;

&lt;p&gt;The solution may vary based on your setup, please comment if you have problems with it and I might add more info to the post.&lt;/p&gt;

&lt;p&gt;❤️&lt;/p&gt;

</description>
      <category>vue</category>
      <category>devtools</category>
      <category>javascript</category>
      <category>webpack</category>
    </item>
  </channel>
</rss>
