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

Add failing test for same file contents #68

Merged
merged 3 commits into from
Jul 16, 2015
Merged

Add failing test for same file contents #68

merged 3 commits into from
Jul 16, 2015

Conversation

hgl
Copy link

@hgl hgl commented Jul 9, 2015

I can confirm that the file is not imported.

@hgl
Copy link
Author

hgl commented Jul 10, 2015

PTAL

I manage to come up with a fix. The crux here is files containing any import rules should not be skipped.

@MoOx
Copy link
Contributor

MoOx commented Jul 15, 2015

From what I understand you are getting some files that looks the same with import(s) + rules but imports refer to different files ?

@hgl
Copy link
Author

hgl commented Jul 16, 2015

Yep, exactly.

@hgl
Copy link
Author

hgl commented Jul 16, 2015

Also I now think skipping files silently might not be a good idea. It can cause some rule failed to be overridden.

For example

@import "foo/red.css";
@import "reset.css";
@import "bar/red.css";

and both foo/red.css and bar/red.css have this content:

body {
    background: url(red.png);
}

reset.css

body {
    background: none;
}

If bar/red.css is skipped, there will be no background on body. And even if the two red.css file have the same file, they refer to different images, so really shouldn't be skipped.

I think skipping files based on absolute url is good enough.

@MoOx
Copy link
Contributor

MoOx commented Jul 16, 2015

Good point. Any objection @magsout ?

@hgl
Copy link
Author

hgl commented Jul 16, 2015

Well, just realize skipping files based on absolutely url is wrong too:

@import "foo/red.css";
@import "reset.css";
@import "foo/red.css";

I think for css, no files should be skipped.

@magsout
Copy link
Member

magsout commented Jul 16, 2015

Also I now think skipping files silently might not be a good idea. It can cause some rule failed to be overridden.

I understand that the test on the hash can introduce a bug on your example. Even though I do not consider it as a real bug. But I try to understand the relevance of your example. It's not really logical to do that, if I may? Or at compile we can specifie that the file is skipped because the same content as such a file.

@hgl
Copy link
Author

hgl commented Jul 16, 2015

@magsout, you can not expect users to be always logical and not make mistakes like this.

I think we should leave the job of removing unnecessary rules to a css compressor.

@MoOx
Copy link
Contributor

MoOx commented Jul 16, 2015

I agree that @hgl example doesn't really make sense in practise.
Maybe we should add an option for this, so people can choose to enable or disable skipping.

@hgl the idea was (for example) to avoid having normalize.css several times if some modules use it.

And importing normalize (still for the example) can override previously defined values... So in both cases, so "bugs" are possible...

@MoOx
Copy link
Contributor

MoOx commented Jul 16, 2015

@hgl you are the first to complain about this "feature", so I guess for now, we should just add an option to allow changing this behavior. What bout skipDuplicates (default to true, in order to add this as a minor change). PR welcome :)
Seems good to you @magsout ?

@magsout
Copy link
Member

magsout commented Jul 16, 2015

What bout skipDuplicates (default to true, in order to add this as a minor change). PR welcome :)

LGTM 👍

@hgl
Copy link
Author

hgl commented Jul 16, 2015

@MoOx what we are currently discussing is if files with the same contents (but contain no imports) should be skipped. But this PR is to not skipping files containing imports (the previous implementation seems to also do that, but with a plain /@import (.*);/ replace, it can fail in many cases).

I hope this PR is still good for merging.

@MoOx
Copy link
Contributor

MoOx commented Jul 16, 2015

Yeap.

MoOx added a commit that referenced this pull request Jul 16, 2015
Add failing test for same file contents
@MoOx MoOx merged commit 78dbf16 into postcss:master Jul 16, 2015
@hgl
Copy link
Author

hgl commented Jul 16, 2015

I still think skipping files with same content is a bad idea. I will open a new issue with a more practical example.

@MoOx
Copy link
Contributor

MoOx commented Jul 16, 2015

#67 ?

@hgl
Copy link
Author

hgl commented Jul 16, 2015

Yep, I will add to that issue. writing it.

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

Successfully merging this pull request may close these issues.

3 participants