10000 improve warn minification · rabbitocat/vue@bc4b7bb · GitHub
[go: up one dir, main page]

Skip to content

Commit bc4b7bb

Browse files
committed
improve warn minification
1 parent d96031e commit bc4b7bb

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

src/util/debug.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
import config from '../config'
22

3-
/**
4-
* Enable debug utilities.
5-
*/
3+
let warn
64

7-
const hasConsole = typeof console !== 'undefined'
8-
9-
/**
10-
* We've got a problem here.
11-
*
12-
* @param {String} msg
13-
*/
14-
15-
export function warn (msg, e) {
16-
if (hasConsole && (!config.silent || config.debug)) {
17-
console.warn('[Vue warn]: ' + msg)
18-
/* istanbul ignore if */
19-
if (config.debug) {
20-
if (e) {
21-
throw e
22-
} else {
23-
console.warn((new Error('Warning Stack Trace')).stack)
5+
if (process.env.NODE_ENV !== 'production') {
6+
const hasConsole = typeof console !== 'undefined'
7+
warn = function (msg, e) {
8+
if (hasConsole && (!config.silent || config.debug)) {
9+
console.warn('[Vue warn]: ' + msg)
10+
/* istanbul ignore if */
11+
if (config.debug) {
12+
if (e) {
13+
throw e
14+
} else {
15+
console.warn((new Error('Warning Stack Trace')).stack)
16+
}
2417
}
2518
}
2619
}
2720
}
21+
22+
export { warn }

src/util/options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ export function resolveAsset (options, type, id) {
374374

375375
export function assertAsset (val, type, id) {
376376
if (!val) {
377-
warn('Failed to resolve ' + type + ': ' + id)
377+
process.env.NODE_ENV !== 'production' && warn(
378+
'Failed to resolve ' + type + ': ' + id
379+
)
378380
}
379381
}

0 commit comments

Comments
 (0)
0