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

Build callback in grunt #33

Closed
funkage opened this issue Dec 17, 2015 · 2 comments
Closed

Build callback in grunt #33

funkage opened this issue Dec 17, 2015 · 2 comments

Comments

@funkage
Copy link

funkage commented Dec 17, 2015

Moved over from (assemble/assemble) [https://github.com/assemble/assemble]. Sorry about that, @jonschlinkert

Hello guys, I've been search high and low for reference on this but to no avail, thus my presence here.

Background
I'm running multiple assemble targets and would like to add a callback that copies a folder of assets (CSS, JS, etc) to the destination directory every time a target build is complete—preferably by referencing to a grunt-contrib-copy module already present.

What does the grunt file look like?

// some grunt configs
assemble: {

            options: {
                site:         '<%= site %>',
                assets:       '<%= site.assets %>',
                data:         '<%= site.data %>',
                helpers:      '<%= site.helpers %>',
                layout:       '<%= site.layout %>',
                layoutdir:    '<%= site.layouts %>',
                partials:     '<%= site.includes %>',
                plugins:      '<%= site.plugins %>'
            },

            target_1: { options: { site_id: 'foobar' }, expand: true, cwd: '<%= site.pages %>/foo/bar', src: '<%= site.pages_src %>', dest: '<%= site.dest %>/foo/bar' },
            target_2: { options: { site_id: 'foobar2' }, expand: true, cwd: '<%= site.pages %>/foo/bar2', src: '<%= site.pages_src %>', dest: '<%= site.dest %>/foo/bar2' }

        }
// more grunt configs

I'm aware of the build method found on this page but I haven't been able to figure out on how to implement it within the grunt file.

Thank you for taking time to read this and activating your brain cells in coming up with an answer.

@jonschlinkert
Copy link
Member

no worries!

Unless I'm missing something, I think you just need to define tasks for that:

grunt.registerTask('foo', ['assemble:foo', 'copy:foo']);
grunt.registerTask('bar', ['assemble:bar', 'copy:bar']);
grunt.registerTask('baz', ['assemble:baz', 'copy:baz']);

If this isn't what you mean, perhaps take a look at the creating tasks page on the grunt docs. hope this helps.

(closing though since we try to keep issues focused on bugs and feature requests)

@funkage
Copy link
Author

funkage commented Dec 17, 2015

Ah, I was looking for something more dynamic:

// some grunt configs
assemble: {

            options: {
                site:         '<%= site %>',
                assets:       '<%= site.assets %>',
                data:         '<%= site.data %>',
                helpers:      '<%= site.helpers %>',
                layout:       '<%= site.layout %>',
                layoutdir:    '<%= site.layouts %>',
                partials:     '<%= site.includes %>',
                plugins:      '<%= site.plugins %>',
                build: function(options, dest) {
                    // something along the lines of:
                    some.grunt.task.caller('copy', {src: 'path/of/src', dest: dest});
                }
            },

            target_1: { options: { site_id: 'foobar' }, expand: true, cwd: '<%= site.pages %>/foo/bar', src: '<%= site.pages_src %>', dest: '<%= site.dest %>/foo/bar' },
            target_2: { options: { site_id: 'foobar2' }, expand: true, cwd: '<%= site.pages %>/foo/bar2', src: '<%= site.pages_src %>', dest: '<%= site.dest %>/foo/bar2' }

        }
// more grunt configs

... because we may end up with 60 assemble targets, but if there isn't an option that's as dynamic, I'll look into what you're recommending. Thanks @jonschlinkert!

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

2 participants