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

css sourcemap comment not included #1387

Closed
Somepub opened this issue Jun 21, 2021 · 1 comment
Closed

css sourcemap comment not included #1387

Somepub opened this issue Jun 21, 2021 · 1 comment

Comments

@Somepub
Copy link

Somepub commented Jun 21, 2021

Hello,

I'm trying to make scss source map implementation with my custom plugin, unfortunately source map comment is being eaten away.

build.onLoad({ filter: /.*/, namespace: "sass" }, (args) => {
      const compiled = sass.renderSync({
        file: args.path,
        sourceMap: pluginArgs.sourceMap,
        outFile: outCss,
        outputStyle: pluginArgs.outputStyle,
        includePaths: ['styles', 'vendor'],
        sourceMapContents: true
      });

      return {
        contents: compiled.css.toString(),
        loader: "css",
      };
    });

compiled.css.toString() returns me:

* {
  background-color: black;
  color: red; }

/*# sourceMappingURL=index.css.map */

but the output of the css file is *{background-color:#000;color:red}

I also looked into legal comments, but that seems to only work with .js, ts files.
Am I doing something wrong or this is a default esbuild behavior?

@evanw
Copy link
Owner

evanw commented Jun 22, 2021

You're not doing something wrong. This is a default esbuild behavior. Source maps in CSS are not supported yet. Just copying the input source map comment over to the output file would be incorrect because the input source map contains mappings for the input file, not the output file. The source map would need to be rewritten by esbuild to get this to work correctly.

Closing as a duplicate of #519.

@evanw evanw closed this as completed Jun 22, 2021
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

2 participants