map.sourcesContent doesn't work together with map.from #916

sormy opened this Issue Nov 15, 2016 · 4 comments


None yet

3 participants

sormy commented Nov 15, 2016
const postcss = require('postcss');
const autoprefixer = require('autoprefixer');

const options = {
  from: 'src/test.css',
  to: 'src/test.css!postcss',
  map: {
    inline: false,
    annotation: false,
    sourcesContent: true,
    from: 'src/test.css'

const instance = postcss([ autoprefixer({ browsers: '>0%' }) ]);

const result = instance.process('.test { border-radius: 5px }', options);


code below will produce sourcesContent: [ null ] instead of sourcesContent: [ '...' ] but will produce correct source name src/test.css.

If i will remove from option then sourcesContent will have correct value but sources will have test.css instead of src/test.css.

So there is no way to keep correct source name together with source content.

Looks like a two defects:

  • options.from with full path truncated to basename by default and source map looses original source file path
  • workaround with keeps correct source file path but doesn't work well with sourcesContent = true (breaks source content)
ai commented Nov 16, 2016

Very weird. I will try to look in this weekend. Feel free to ping me in Monday if I will forget.

ai commented Nov 16, 2016

Will it work if you will set to: 'src/test.css'? Will it work if you set absolute path to from and to?

sormy commented Nov 17, 2016

@ai no, it doesn't

uncleyo commented Nov 17, 2016

Hi, I think I hit the same issue when running postcss on node-sass output.
if map.from is set, the resulting .map file only references the empty virtual file, while all original sass maps are gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment