Skip to content

Commit

Permalink
support devtools in production build as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 30, 2016
1 parent 7cab529 commit 2c2894d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
12 changes: 7 additions & 5 deletions src/batcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { inBrowser, warn, nextTick } from './util/index'
import config from './config'
import {
warn,
nextTick,
devtools
} from './util/index'

// we have two separate queues: one for directive updates
// and one for user watcher registered via $watch().
Expand Down Expand Up @@ -36,10 +40,8 @@ function flushBatcherQueue () {
runBatcherQueue(userQueue)
// dev tool hook
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production') {
if (inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('flush')
}
if (devtools) {
devtools.emit('flush')
}
resetBatcherState()
}
Expand Down
23 changes: 12 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Vue from './instance/vue'
import directives from './directives/public/index'
import elementDirectives from './directives/element/index'
import filters from './filters/index'
import { inBrowser } from './util/index'
import { inBrowser, devtools } from './util/index'

Vue.version = '1.0.15'

Expand All @@ -28,14 +28,15 @@ Vue.options = {
export default Vue

// devtools global hook
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' && inBrowser) {
if (window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('init', Vue)
} else if (/Chrome\/\d+/.test(navigator.userAgent)) {
console.log(
'Download the Vue Devtools for a better development experience:\n' +
'https://github.com/vuejs/vue-devtools'
)
}
/* istanbul ignore next */
if (devtools) {
devtools.emit('init', Vue)
} else if (
process.env.NODE_ENV !== 'production' &&
inBrowser && /Chrome\/\d+/.test(navigator.userAgent)
) {
console.log(
'Download the Vue Devtools for a better development experience:\n' +
'https://github.com/vuejs/vue-devtools'
)
}
4 changes: 4 additions & 0 deletions src/util/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export const inBrowser =
typeof window !== 'undefined' &&
Object.prototype.toString.call(window) !== '[object Object]'

export const devtools =
inBrowser &&
window.__VUE_DEVTOOLS_GLOBAL_HOOK__

export const isIE9 =
inBrowser &&
navigator.userAgent.toLowerCase().indexOf('msie 9.0') > 0
Expand Down

0 comments on commit 2c2894d

Please sign in to comment.