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

Partial scss files automatically compiled #785

Open
alex88 opened this issue Jan 12, 2016 · 5 comments
Open

Partial scss files automatically compiled #785

alex88 opened this issue Jan 12, 2016 · 5 comments

Comments

@alex88
Copy link

alex88 commented Jan 12, 2016

I'm not sure if it's a bug or a non-correct use of the library, I've create a sample app to demonstrate the issue: https://github.com/alex88/assetic-test

I've configured assetic this way so I don't have to add the filter in all the stylesheets declarations:

assetic:
    debug:            "%kernel.debug%"
    use_controller:   "%kernel.debug%"
    filters:
        scssphp:
            apply_to:  "\\.scss$"
            formatter: 'Leafo\ScssPhp\Formatter\Compressed'

and I've this sample structure (bootstrap source has something like that) https://github.com/alex88/assetic-test/tree/master/web/assets/scss

Basically there is bootstrap.scss which is the main file and it's what is included in the template, then there is a _mixins.scss partial that includes the mixins and a _something.scss partial which includes a scss rule using the mixin provided by the previous partial.

Now, assetic:dump works fine since includes the files in the various stylesheets declarations in the templates, and so includes the partials in the correct order and dependency.

assetic:watch instead since tries to compile all files gives error on the _something.scss partial since doesn't include the mixins partial.

Is that an expected behaviour since that's what the apply_to setting actually does or is it a bug?

@alex88
Copy link
Author

alex88 commented Jan 12, 2016

I've tried to manually exclude files starting with an underscore changing the apply_to to ^[^_]*\.scss$, however it still tries to compile the partials due the function in ScssphpFilter:

ctImports($content) as $match) {
    $file = $sc->findImport($match);
    if ($file) {
        $children[] = $child = $factory->createAsset($file, array(), array('root' => $loadPath));
        $child->load();
        $children = array_merge($children, $this->getChildren($factory, $child->getContent(), $loadPath));
    }
}

which seems to automatically create an asset for the dependant files, maybe worth checking if those files are in the apply_to filter?

@alex88
Copy link
Author

alex88 commented Jan 12, 2016

So the automatic load of the child asset makes the compiler automatically run on it.
I've tried to exclude the child by checking the underscore at the beginning and it actually worked without any error (ofc this is the hardcoded solution in my case)

@Viburnum
Copy link

+1

1 similar comment
@koddistortion
Copy link

+1

@Viburnum
Copy link

Viburnum commented Dec 2, 2016

Added a flag to ignore partial files in the ScssphpFilter #830

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

3 participants