8000 support devtools in production build as well · codeclever/vue@2c2894d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c2894d

Browse files
committed
support devtools in production build as well
1 parent 7cab529 commit 2c2894d

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/batcher.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { inBrowser, warn, nextTick } from './util/index'
21
import config from './config'
2+
import {
3+
warn,
4+
nextTick,
5+
devtools
6+
} from './util/index'
37

48
// we have two separate queues: one for directive updates
59
// and one for user watcher registered via $watch().
@@ -36,10 +40,8 @@ function flushBatcherQueue () {
3640
runBatcherQueue(userQueue)
3741
// dev tool hook
3842
/* istanbul ignore if */
39-
if (process.env.NODE_ENV !== 'production') {
40-
if (inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
41-
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('flush')
42-
}
43+
if (devtools) {
44+
devtools.emit('flush')
4345
}
4446
resetBatcherState()
4547
}

src/index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Vue from './instance/vue'
22
import directives from './directives/public/index'
33
import elementDirectives from './directives/element/index'
44
import filters from './filters/index'
5-
import { inBrowser } from './util/index'
5+
import { inBrowser, devtools } from './util/index'
66

77
Vue.version = '1.0.15'
88

@@ -28,14 +28,15 @@ Vue.options = {
2828
export default Vue
2929

3030
// devtools global hook
31-
/* istanbul ignore if */
32-
if (process.env.NODE_ENV !== 'production' && inBrowser) {
33-
if (window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
34-
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('init', Vue)
35-
} else if (/Chrome\/\d+/.test(navigator.userAgent)) {
36-
console.log(
37-
'Download the Vue Devtools for a better development experience:\n' +
38-
'https://github.com/vuejs/vue-devtools'
39-
)
40-
}
31+
/* istanbul ignore next */
32+
if (devtools) {
33+
devtools.emit('init', Vue)
34+
} else if (
35+
process.env.NODE_ENV !== 'production' &&
36+
inBrowser && /Chrome\/\d+/.test(navigator.userAgent)
37+
) {
38+
console.log(
39+
'Download the Vue Devtools for a better development experience:\n' +
40+
'https://github.com/vuejs/vue-devtools'
41+
)
4142
}

src/util/env.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export const inBrowser =
66
typeof window !== 'undefined' &&
77
Object.prototype.toString.call(window) !== '[object Object]'
88

9+
export const devtools =
10+
inBrowser &&
11+
window.__VUE_DEVTOOLS_GLOBAL_HOOK__
12+
913
export const isIE9 =
1014
inBrowser &&
1115
navigator.userAgent.toLowerCase().indexOf('msie 9.0') > 0

0 commit comments

Comments
 (0)
0