Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Concat all Bower-installed libraries into CSS and JS #75

Closed
Grawl opened this issue Sep 16, 2014 · 4 comments
Closed

Concat all Bower-installed libraries into CSS and JS #75

Grawl opened this issue Sep 16, 2014 · 4 comments

Comments

@Grawl
Copy link
Contributor

Grawl commented Sep 16, 2014

It's strange that I need to link manually every installed component into my template like this:

        // build:js(client) scripts/global.js
        script(src='/bower_components/jquery/dist/jquery.js')
        script(src='/bower_components/foundation/js/vendor/fastclick.js')
        script(src='/bower_components/foundation/js/vendor/jquery.cookie.js')
        script(src='/bower_components/foundation/js/vendor/placeholder.js')
        <…>
        script(src='/bower_components/fotorama/fotorama.js')
        // endbuild

when we can use grunt-bower to copy them and then concat all to vendor.{css,js} and then connect only two additional files or just into app.js/main.css directly.

It's simple:

        bower:
            dev:
                dest: 'client/vendor/'
        concat:
            scripts:
                src: 'client/vendor/*.js'
                dest: 'client/.server/scripts/vendor.js'
            styles:
                src: 'client/vendor/*.css'
                dest: 'client/.server/scripts/vendor.css'

Or something similar. It would be very very simpler than including them into templates with special comments manually.

Better to leave this trick for a Bower packages with wrong main string in their bower.json files. I seen a one.

@larsonjj
Copy link
Owner

The problem here lies in the loading order of scripts and stylesheets. If you add scripts that depend on other scripts to load first (i.e. Backbone needs jQuery and Lo-dash to load first), you will run into trouble with the solution that you posted. Plus, bower packages can add a lot of extra files that I wouldn't want copied over and I'm not really sure how grunt-bower handles this.

Currently, I think the <!-- build --> comments are the most flexible way of handling this.

@Grawl
Copy link
Contributor Author

Grawl commented Sep 17, 2014

Okay I understand.

@larsonjj
Copy link
Owner

Looks like this is resolved. Closing out.

@Grawl
Copy link
Contributor Author

Grawl commented Sep 19, 2014

But wait, grunt-bower uses package dependencies, i.e. if backbone depends on jquery so it will be concatinated after jquery. So no need to manage it manually. It you want it, you can participate into curist/grunt-bower#19 discussion.

@Grawl Grawl mentioned this issue Nov 12, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants