Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: Use basename for __file in production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
znck committed Jul 31, 2018
1 parent 8ef7d8f commit 541a824
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/assembler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SourceMapGenerator } from 'source-map'
import { SFCCompiler, DescriptorCompileResult } from './compiler'
import { merge } from './source-map'
import * as path from 'path'

// const merge = require('merge-source-map')

Expand Down Expand Up @@ -221,9 +222,8 @@ export function assembleFromSource(
) {
const component = (typeof script === 'function' ? script.options : script) || {}
if (${e(!compiler.template.isProduction)}) {
component.__file = ${e(filename)}
}
// For security concerns, we use only base name in production mode.
component.__file = ${compiler.template.isProduction ? e(path.basename(filename)) : e(filename)}
if (!component.render) {
component.render = template.render
Expand Down Expand Up @@ -302,7 +302,7 @@ export function assembleFromSource(
.replace('var staticRenderFns =', 'var __vue_staticRenderFns__ =')
.replace('render._withStripped =', '__vue_render__._withStripped =')}
/* style */
const __vue_inject_styles__ = ${hasStyle} ? function (inject) {
const __vue_inject_styles__ = ${hasStyle ? `function (inject) {
if (!inject) return
${styles.map((style, index) => {
const source = IDENTIFIER.test(style.source)
Expand Down Expand Up @@ -333,7 +333,7 @@ export function assembleFromSource(
: '')
)
})}
} : undefined
}` : 'undefined'}
/* scoped */
const __vue_scope_id__ = ${hasScopedStyle ? e(scopeId) : 'undefined'}
/* module identifier */
Expand Down

0 comments on commit 541a824

Please sign in to comment.