Ver Fonte

control devtools availability behind config flag (close #2453)

Evan You há 10 anos atrás
pai
commit
988fa127c2
3 ficheiros alterados com 21 adições e 11 exclusões
  1. 1 1
      src/batcher.js
  2. 7 0
      src/config.js
  3. 13 10
      src/index.js

+ 1 - 1
src/batcher.js

@@ -42,7 +42,7 @@ function flushBatcherQueue () {
   runBatcherQueue(userQueue)
   // dev tool hook
   /* istanbul ignore if */
-  if (devtools) {
+  if (devtools && config.devtools) {
     devtools.emit('flush')
   }
   resetBatcherState()

+ 7 - 0
src/config.js

@@ -35,6 +35,13 @@ const config = {
 
   warnExpressionErrors: true,
 
+  /**
+   * Whether to allow devtools inspection.
+   * Disabled by default in production builds.
+   */
+
+  devtools: process.env.NODE_ENV !== 'production',
+
   /**
    * Internal flag to indicate the delimiters have been
    * changed.

+ 13 - 10
src/index.js

@@ -1,6 +1,7 @@
 import Vue from './instance/vue'
 import installGlobalAPI from './global-api'
 import { inBrowser, devtools } from './util/index'
+import config from './config'
 
 installGlobalAPI(Vue)
 
@@ -10,14 +11,16 @@ export default Vue
 
 // devtools global hook
 /* istanbul ignore next */
-if (devtools) {
-  devtools.emit('init', Vue)
-} else if (
-  process.env.NODE_ENV !== 'production' &&
-  inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)
-) {
-  console.log(
-    'Download the Vue Devtools for a better development experience:\n' +
-    'https://github.com/vuejs/vue-devtools'
-  )
+if (config.devtools) {
+  if (devtools) {
+    devtools.emit('init', Vue)
+  } else if (
+    process.env.NODE_ENV !== 'production' &&
+    inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)
+  ) {
+    console.log(
+      'Download the Vue Devtools for a better development experience:\n' +
+      'https://github.com/vuejs/vue-devtools'
+    )
+  }
 }