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

sourceRoot option #240

Closed
ai opened this issue Mar 4, 2015 · 31 comments
Closed

sourceRoot option #240

ai opened this issue Mar 4, 2015 · 31 comments

Comments

@ai
Copy link
Member

ai commented Mar 4, 2015

We need to add sourceRoot option to map generator.

For example, right now gulp-postcss change root of sources manually. Option will be very helpful in this case.

/cc @w0rm

@ai
Copy link
Member Author

ai commented Jul 15, 2015

@w0rm do we really need it?

@w0rm
Copy link
Member

w0rm commented Jul 15, 2015

@ai this is not really critical, I don't mind keeping it as it is now.

@ai
Copy link
Member Author

ai commented Jul 18, 2015

i think we can live without this feature. Anyway PR will be welcome.

@ai ai closed this as completed Jul 18, 2015
@ai ai removed the 5.0 label Aug 19, 2015
@alexander-akait
Copy link

@ai We need this feature.
I write plugin for rebase url on sourcemap sources. i get error

Error in plugin 'css-rebase-urls'
Message:
    "themes/insteria/font-awesome/less/path.less" is not in the SourceMap.

Real path "src/themes/insteria/font-awesome/less/path.less"
I use code

console.log(decl.source.input.origin(
    decl.source.start.line,
    decl.source.start.column
));

Before less compile and concat css. Some files in less format, some in css format.
Base directory sources and build are difference.

@ai ai reopened this Sep 22, 2015
@alexander-akait
Copy link

in fast way i use this code

decl.source.input.map.consumer().sourceRoot = '/my/path/to/source';
// Some logics...
decl.source.input.map.consumer().sourceRoot = null;

but it is bad code :(. Maybe someone you know can help

@difosfor
Copy link

difosfor commented Nov 4, 2015

Hmm ran into this with our build tool (https://github.com/exmg/nbob) as well. Patching it for now like the gulp-postcss plugin does (as mentioned above), but would enjoy an option for this as well.

@ai
Copy link
Member Author

ai commented Nov 4, 2015

Welcome for PR :D

@alexander-akait
Copy link

@ai need feature, because using gulp-postcss with options to, need for postcss-import, break sourcemaps :( I will try to investigate the issue, but do not know postcss code as need to resolve this problem.

@TrySound
Copy link
Member

@evilebottnawi Doesn't need at all. Where did you find that?

@alexander-akait
Copy link

@TrySound find what? Problem? (postcss/gulp-postcss#64)

@TrySound
Copy link
Member

@evilebottnawi Using with postcss-import

@alexander-akait
Copy link

@TrySound sorry, postcss-import need this options for resolve path to assets (local, node_modules), source and destination directory may be different and resolve not working without to options. Example i have fonts in src/theme/app/css/app.css and using font awesome from local /src/theme/font-awesome/..., but my dist directory public/assets/app/css.
postcss/gulp-postcss#64 (comment)

@TrySound
Copy link
Member

@evilebottnawi postcss-import do not need this option. It handle only from postcss option.

@alexander-akait
Copy link

@TrySound
Copy link
Member

@evilebottnawi postcss-copy is not postcss-import.

@alexander-akait
Copy link

@TrySound i know, about this issue postcss/gulp-postcss#64 (comment), if i set option to, my sourcemap wrong, if i not set option to, postcss-copy and postcss-url not resolve right my path to files (fonts, images).

@TrySound
Copy link
Member

@evilebottnawi I see, but your mention to postcss-import doesn't make sense.

@alexander-akait
Copy link

@TrySound I made a mistake and then correct it, be sure to focus on this rather than on solving the problem?

@TrySound
Copy link
Member

That's what I wanted to see.:)

@alexander-akait
Copy link

@TrySound maybe help or just offtop?

@TrySound
Copy link
Member

I response for postcss-import and was confused with your mention. I don't have ideas.

@Saturate
Copy link

Saturate commented Mar 8, 2016

To fix sindresorhus/gulp-autoprefixer#55 we need this.

I did a pull-request (sindresorhus/gulp-autoprefixer#61) but as seen in the comments from the owner, it should be fixed here, as other plugin authors will benefit as well, from this change.

@ai
Copy link
Member Author

ai commented Mar 8, 2016

@Saturate can you make a PR here?

@Saturate
Copy link

Saturate commented Mar 8, 2016

@ai I'll have a look at it later.

@ai ai added this to the 5.1 milestone Mar 8, 2016
@ai
Copy link
Member Author

ai commented Mar 10, 2016

@Saturate it is last version for 5.1 release :)

@ghost
Copy link

ghost commented Mar 10, 2016

While this is being looked at, should an extensions array option be added as well? See: postcss/postcss-import#52 and madyankin/postcss-modules#13

Haven't looked in depth at the proposed solutions yet, but perhaps a simple and elegant solution would be to handle file resolving in PostCSS rather than passing down additional parameters to the plugins, so perhaps PostCSS could pass down a resolving function in the API's opts object? that function would return an absolute file path or an error if the file was not found.

@ai
Copy link
Member Author

ai commented Mar 10, 2016

@tarikihm sourceRoot it is a thing only for source map. It is not relevant for looking paths from this issues.

@ghost
Copy link

ghost commented Mar 11, 2016

Got it, sorry I skimmed through a bit too quickly, still, is there a way to avoid having to pass file resolving options to each plugin? Would it make sense that it gets handled/supervised by PostCSS?

@ai
Copy link
Member Author

ai commented Mar 11, 2016

@tarikihm open a new issue for it.

@ai
Copy link
Member Author

ai commented May 14, 2016

OK. I will close this issue again if nobody want to implement it.

@ai ai closed this as completed May 14, 2016
@ai ai removed this from the 5.1 milestone May 14, 2016
@aleclarson
Copy link

Here's a workaround:

const res = await postcss().process(code, opts);
res.map._sourceRoot = '/path/to/root';

assert(res.map.toJSON().sourceRoot == res.map._sourceRoot);

The sourceRoot option seems like it should exist for the sake of completeness.

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

7 participants