vue-loader icon indicating copy to clipboard operation
vue-loader copied to clipboard

Invalid path for sourcemap

Open nathannau opened this issue 4 years ago • 8 comments

What problem does this feature solve?

Path in sourcemap don't match with real path.

What does the proposed API look like?

Actualy :

image

Expected :

image

Why you don't use full path in lib/index.js (63-73) ?

  const filename = path.basename(resourcePath)
  const context = rootContext || process.cwd()
  const sourceRoot = path.dirname(path.relative(context, resourcePath))

  const descriptor = parse({
    source,
    compiler: options.compiler || loadTemplateCompiler(loaderContext),
    filename,
    sourceRoot,
    needMap: sourceMap
  })

should be

  const filename = resourcePath
  const context = rootContext || process.cwd()
  const sourceRoot = path.dirname(path.relative(context, resourcePath))

  const descriptor = parse({
    source,
    compiler: options.compiler || loadTemplateCompiler(loaderContext),
    filename,
    sourceRoot,
    needMap: sourceMap
  })

or

  const filename = path.basename(resourcePath)
  const context = rootContext || process.cwd()
  const sourceRoot = path.dirname(path.relative(context, resourcePath))

  const descriptor = parse({
    source,
    compiler: options.compiler || loadTemplateCompiler(loaderContext),
    filename: resourcePath,
    sourceRoot,
    needMap: sourceMap
  })

nathannau avatar Mar 29 '20 13:03 nathannau

+1

lianer avatar Sep 01 '21 07:09 lianer

I think there probably should ` const { target, request, minimize, sourceMap, rootContext, resourcePath, resourceQuery = '' } = loaderContext

... const descriptor = parse({ source, compiler: options.compiler || loadTemplateCompiler(loaderContext), filename: request, needMap: sourceMap })`

becase if we ues resourcePath style will use the same filename with script image

lingqiao123 avatar Jan 10 '22 12:01 lingqiao123

I have the same problem!

1593292349 avatar Dec 30 '22 16:12 1593292349

I think there probably should ` const { target, request, minimize, sourceMap, rootContext, resourcePath, resourceQuery = '' } = loaderContext

... const descriptor = parse({ source, compiler: options.compiler || loadTemplateCompiler(loaderContext), filename: request, needMap: sourceMap })`

becase if we ues resourcePath style will use the same filename with script image

Your solution seems to work!

1593292349 avatar Dec 30 '22 16:12 1593292349

我认为可能应该const {target,request,minimize,sourceMap,rootContext,resourcePath,resourceQuery =''} = loaderContext ... const 描述符 = parse({ 源, 编译器: options.compiler || loadTemplateCompiler(loaderContext), 文件名: request, needMap: sourceMap }) 因为如果我们使用resourcePath样式将使用与脚本相同的文件名图像

您的解决方案似乎有效!

这个具体要怎么进行修改

kiraraty avatar Jul 03 '23 09:07 kiraraty

@kiraraty image 把filename改为request

1593292349 avatar Jul 03 '23 09:07 1593292349

@kiraraty image 把filename改为request

对应vue-loader版本多少,谢谢

kiraraty avatar Jul 03 '23 09:07 kiraraty

@kiraraty vue2我用的15.10.1

1593292349 avatar Jul 03 '23 09:07 1593292349