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

Output append #19

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

fromthecove
Copy link
Contributor

Matt,

You've probably figured out by now that I'm using Potion on project and extending/modifying it to suit my needs. I know that not everyone will have the same needs I do, but I figured it would be better to submit each of my modifications as pull requests in case you decide some of them are worth integrating with your core project.

This one is a new potion configuration option called output_append

My Use Case

Sometimes, especially during development, I want to process multiple SCSS files into individual CSS files that are then included on different pages of my project individually. So, given the following file structure, I might have 3 pages on a project and each would individually want to include its own specific CSS.

/resources
    /assets
        /sass
            /pages
                page1.scss
                page2.scss
                page3.scss

The only way to do that with Potion right now is to setup three individual potions in the configuration, which grows tiresome as I add more pages to the project. Instead, I wanted to be able to have a single potion that would export sass/pages/*.scss to individual CSS files. Setting output = false gets me part of the way there, but the resulting files keep their exact file names, leading to .scss files, not .css files.

My solution: output_append.

This new, optional parameter may be set on any potion, and is simply concatenated to the end of the resulting asset. Thus the following potion is possible:

     //
    // Page-specific CSS
    [
        // Resources, relative paths to 'resource_path' above, can be any valid file or glob pattern
        'resources' => [
            '/sass/pages/*.scss',
        ],
        'filters' => [
            'css_import',
            'css_rewrite',
            'css_scssphp',
        ],
        'output'    => FALSE, // keep files separate
        'output_append' => '.css'
    ],

That would cause every scss file in /sass/pages to be processed into an individual file that would then have .css appended to the resulting asset name, which I could then include individually on any page of my project as required.

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.

1 participant