Skip to content

Commit

Permalink
perf(plugin-vue-jsx): only gen source map when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 5, 2021
1 parent d914b54 commit bfa8530
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/plugin-vue-jsx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const hash = require('hash-sum')
*/
module.exports = function vueJsxPlugin(options = {}) {
let needHmr = false
let needSourceMap = true

return {
name: 'vue-jsx',
Expand All @@ -31,6 +32,7 @@ module.exports = function vueJsxPlugin(options = {}) {

configResolved(config) {
needHmr = config.command === 'serve' && !config.isProduction
needSourceMap = config.command === 'serve' || !!config.build.sourcemap
},

transform(code, id) {
Expand All @@ -47,7 +49,7 @@ module.exports = function vueJsxPlugin(options = {}) {
const result = babel.transformSync(code, {
ast: true,
plugins,
sourceMaps: true,
sourceMaps: needSourceMap,
sourceFileName: id
})

Expand Down

0 comments on commit bfa8530

Please sign in to comment.