Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid path for sourcemap #1657

Open
nathannau opened this issue Mar 29, 2020 · 8 comments
Open

Invalid path for sourcemap #1657

nathannau opened this issue Mar 29, 2020 · 8 comments

Comments

@nathannau
Copy link

nathannau commented Mar 29, 2020

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
  })
@lianer
Copy link

lianer commented Sep 1, 2021

+1

@lingqiao123
Copy link

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

@1593292349
Copy link

I have the same problem!

@1593292349
Copy link

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!

@kiraraty
Copy link

kiraraty commented Jul 3, 2023

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

您的解决方案似乎有效!

这个具体要怎么进行修改

@1593292349
Copy link

@kiraraty
image
把filename改为request

@kiraraty
Copy link

kiraraty commented Jul 3, 2023

@kiraraty image 把filename改为request

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

@1593292349
Copy link

@kiraraty vue2我用的15.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants