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

'Target' option be able to receive a function #334

Closed
danielppereira opened this issue Aug 1, 2014 · 4 comments
Closed

'Target' option be able to receive a function #334

danielppereira opened this issue Aug 1, 2014 · 4 comments
Assignees

Comments

@danielppereira
Copy link

I'm using grunt css-min, and i'm trying doing this

options: {
    keepSpecialComments: 0,
        // string works
    // target: 'webroot/css/banking/'
        // function doesn't work
    target: function(src){
        return src;
    }
}

This option could accept a function, so that could work dynamically with each src

@GoalSmashers
Copy link
Contributor

Interesting idea. Could you give me a real world usage scenario?

@danielppereira
Copy link
Author

Sure!

My 'css-min' task have two targets: minification and concat. But let's focus on concat. ;D
As i have multiple src-dest mappings per-target, i'm using the File Object Format. So, each one needs a specific target path to rewrite their images path on the dest (concat) file. Here is my code:

concat: {
        options: {
            keepSpecialComments: 0,
                        // This isn't work in clean-css yet, but i'm think is what i need
            target: function(path){
                return path;
            }
        },
        files: {
            // BANKING - Template Master
            '<%= app.src %>webroot/css/banking/bundle-app-banking.min.css': [
                '<%= app.src %>webroot/css/banking/estilo.css'
            ],
            '<%= app.src %>webroot/css/banking/bundle-vendor-banking.min.css': [
                '<%= app.src %>webroot/js/ui/css/no-theme/jquery-ui-1.7.2.custom.min.css',
                '<%= app.src %>webroot/js/yui-calendar/calendar.min.css',
                '<%= app.src %>webroot/js/yui-calendar/container.min.css'
            ],
            // BANKING - Template Popup
            '<%= app.src %>webroot/css/banking/bundle-app-banking-popup.min.css': [
                '<%= app.src %>webroot/css/banking/estilo.css',
                '<%= app.src %>webroot/css/yui-calendar/container_minhaconta.min.css'
            ],
            '<%= app.src %>webroot/css/banking/bundle-vendor-banking-popup.min.css': [
                '<%= app.src %>webroot/js/banking/thickbox/thickbox.min.css',
                '<%= app.src %>webroot/js/ui/css/no-theme/jquery-ui-1.7.2.custom.min.css'
            ],
            //CHECKOUT
            '<%= app.src %>webroot/css/checkout3/bundle-app-checkout.min.css': [
                '<%= app.src %>webroot/css/checkout3/estilo.css'
            ],
            '<%= app.src %>webroot/css/checkout2.1/bundle-vendor-checkout.min.css': [
                '<%= app.src %>webroot/css/checkout2.1/jquery-ui-1.8.16.custom.min.css',
                '<%= app.src %>webroot/js/checkout2.1/thickbox/thickbox.css',
                '<%= app.src %>webroot/css/checkout2.1/uniform.default.css'
            ],
            //SITE
            '<%= app.src %>webroot/css/site/bundle-app-site.min.css': [
                '<%= app.src %>webroot/css/site/fonts.css',
                '<%= app.src %>webroot/css/site/home.css'
            ],
            '<%= app.src %>webroot/css/site/bundle-vendor-site.min.css': [
                '<%= app.src %>webroot/css/site/fancybox.css'
            ]
        }
    }

Nowadays, the 'target' option accept just a string. But in my example, just one defined path doesn't work with multiple targets. I think that accepting a function, i can pass the filepath of each dest to the target option.

The function ideia maybe isn't the best solution, but i think you get the point.
thks

@GoalSmashers
Copy link
Contributor

Hi @danielppereira - interesting concept which generally makes sense to me. Let me give it a try to have a better idea how to handle it.

Not sure if it's going to find its way into 2.3 release as #125 is a quite a big chunk!

@GoalSmashers GoalSmashers added this to the 2.4 milestone Aug 23, 2014
@GoalSmashers GoalSmashers self-assigned this Aug 23, 2014
@jakubpawlowicz jakubpawlowicz modified the milestones: future, 3.1 Dec 18, 2014
@jakubpawlowicz jakubpawlowicz modified the milestones: future, ~future~ Jan 4, 2017
@jakubpawlowicz
Copy link
Collaborator

4.0 gets rid of target option in favor to simpler rebaseTo interface, however it'll also feature transformProperty callback which will enable some sort of direct property manipulation, hopefully aiding URL rebasing too, see #863.

@jakubpawlowicz jakubpawlowicz removed this from the ~future~ milestone Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants