Skip to content

Error generating CSS sourcemap when using SCSS #9969

Closed
@MuTsunTsai

Description

@MuTsunTsai

Vue version

3.4.3

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-3fervz?file=package.json

Steps to reproduce

Open the minimal repo, and execute npm run build to see the error.

What is expected?

The project should build and create a dist folder, containg a js file, a css file, and their sourcemaps.

What is actually happening?

The following error appear:

[ERROR] "version" is a required argument. [plugin vue]

System Info

No response

Any additional comments?

I've tracked this issue down to its source:

result.map.toJSON
? result.map.toJSON()
: JSON.parse(result.map.toString()),

During execution, result.map is, for some reason, not a JSON object, but a Buffer representing the JSON string. And because toJSON method is actually defined on a Buffer, this part of the code calls toJSON method on the Buffer object, resulting in the wrong format later on.

A quick fix I found would be replacing that part by the following:

!(result.map instanceof Buffer) && result.map.toJSON 
   ? result.map.toJSON() 
   : JSON.parse(result.map.toString()), 

I've made a PR based on this observation, but I'm not totally sure if this is the right way to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions