Skip to content

Conversation

@ancpru
Copy link

@ancpru ancpru commented Sep 1, 2016

The current implementation goes up 4 directory levels when a relative path is specified in a css (scss), thus leading to the following effect:

let's say, the root of the typo3 installation is

http://localhost/foo/bar

The generated css is thus available under

http://localhost/foo/bar/typo3temp/DynCss/style-xxxxxxx.css

If the scss contains a url reference, the post-processor rewrites the url and prefixes it with ../../../../

That means, relative to the generated css, it goes up to

http://localhost/

and looks for the orignal subdirectory (e.g. typo3conf) there.

This might not have a negative effect if the typo3 installation is in the root of the webspace, but causes this problem if it's installed in a subdirectory.

I modified the Parser to go up 2 levels instead of 4, which would be always the root of the typo3 installation as the generated .css is stored under typo3temp/DynCss

It works for me and I hope that this change does not break anything. I do not see a problem, but I admit that I do not really understand why it's currently going 4 levels up instead of 2. There must be a reason for that, but I do not really see it. Could anybody please explain?

An alternative might be to introduce support for "FILE:EXT":-Prefix in url.

Andreas

@kaystrobach
Copy link
Owner

could you please rebase that PR - thank you

@ancpru
Copy link
Author

ancpru commented May 4, 2017

Could you please add my modifications manually. I did not touch the project for quite a long time now and it seems that I've created a little bit of a version mess. My modifications were quite simple:


            // the generated css is assumed to be in typo3temp/DynCss, thus we read the typo3 
            // install root by going up 2 levels
	return '../../' . dirname($this->removePrefixFromString(PATH_site, $this->inputFilename)) . '/' . $url;

instead of

    return '../../../../'.dirname($this->removePrefixFromString(PATH_site, $this->inputFilename)).'/'.$url;

in Classes/Parser/AbstractParser.php at line 206

The second modificaiton:


  •   	'../../Public/Contrib/bootstrap/fonts/glyphicons-halflings-regular.eot' => '../../typo3conf/ext/dyncss/Resources/Public/Less/../../Public/Contrib/bootstrap/fonts/glyphicons-halflings-regular.eot',
    

instead of


  •   	'../../Public/Contrib/bootstrap/fonts/glyphicons-halflings-regular.eot' => '../../../../typo3conf/ext/dyncss/Resources/Public/Less/../../Public/Contrib/bootstrap/fonts/glyphicons-halflings-regular.eot',
    

in Tests/Unit/Parser/DummyParserTest.php

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.

2 participants