Giter Club home page Giter Club logo

grunt-bower-concat's Introduction

Bower components builder for Grunt

Powered by You Build Status

Automatic concatenation of installed Bower components (JS and/or CSS) in the right order.

Installation

This plugin requires Grunt 0.4.

$ npm install grunt-bower-concat --save-dev

Configuration

Add somewhere in your Gruntfile.js:

grunt.loadNpmTasks('grunt-bower-concat');

Inside your Gruntfile.js file add a section named bower_concat. See Parameters section below for details.

Options

separator

Type: String Default: grunt.util.linefeed

Concatenated files will be joined on this string. If you're post-processing concatenated JavaScript files with a minifier, you may need to use a semicolon ';\n' as the separator. Separator is only applied to concatenated JS files.

options: { separator : ';' }

Parameters

dest

Type: Object, required. Defines the filetypes to be concatenated into a destination file. Where the key is the file extension (without the dot) and the value is the destination file. E.g:

dest: {
    js: 'build/_bower.js',
    scss: 'build/_bower.scss',
    coffee: 'build/_bower.coffee'
}

Also this version still supports this field to be a String, but this is deprecated: (Deprecated) Type: String, defines into which file all .js files should be concatenated.

Name of JS file where result of concatenation will be saved.

exclude

Type: String|Array, optional.

List of components you want to exclude.

exclude: [
  'jquery',
  'modernizr'
]

include

Type: String|Array, optional.

By default bower-concat will include all installed in project components. Using include option you can manually specify which components should be included.

include: [
  'underscore',
  'backbone'
]

dependencies

Type: Object, optional.

Unfortunately not all Bower components list their dependencies. If components concatenate in the wrong order, use this option to manually specify dependencies for those components.

dependencies: {
  'underscore': 'jquery',
  'mygallery': ['jquery', 'fotorama']
}

mainFiles

Type: Object, optional.

Some Bower components don’t list their main files or (more likely) don’t have bower.json file at all. In this case bower-concat will try to guess main file but sometimes it can’t or choose wrong one. You could explicitly define main files for that components.

mainFiles: {
  'svg.js': 'dist/svg.js',
  'mygallery': ['src/base.js', 'src/gallery.js', 'src/style.css']
}

callback

Type: Function, optional.

This function will be called for every Bower component and allows you to change main files chosen by bower-concat.

callback: function(mainFiles, component) {
  return _.map(mainFiles, function(filepath) {
    // Use minified files if available
    var min = filepath.replace(/\.js$/, '.min.js');
    return grunt.file.exists(min) ? min : filepath;
  });
}

process

Type: Function, optional.

This function will be called for every Bower component and allows you to change the contents of every file.

process: function(src) {
	// wrap each library in a self executing function with "use strict"
  return "\n" +
    ";(function( window, jQuery, angular, undefined ){ \n 'use strict';\n\n" +
    src +
    "\n\n}( window, jQuery, angular ));";
}

bowerOptions

Type: Object, optional.

Bower specific options that will be passed in during the bower.commands calls.

bowerOptions: {
  relative: false
}

includeDev

Type: Boolean, default: false.

Include devDependencies along with regular dependencies.

Config Example

bower_concat: {
  all: {
    dest: {
      'js': 'build/_bower.js',
      'css': 'build/_bower.css'
    },
    exclude: [
      'jquery',
      'modernizr'
    ],
    dependencies: {
      'underscore': 'jquery',
      'backbone': 'underscore',
      'jquery-mousewheel': 'jquery'
    },
    bowerOptions: {
      relative: false
    }
  }
}

Changelog

The changelog can be found on the Releases page.


License

The MIT License, see the included License.md file.

grunt-bower-concat's People

Contributors

alwin-rewedigital avatar danifornells avatar epferrari avatar karelvuong avatar kevinschaul avatar keyes avatar mattmcneeney avatar philippbosch avatar readmecritic avatar sapegin avatar seanhess avatar servel333 avatar vstukanov avatar zidom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-bower-concat's Issues

Can’t detect main file for * component

I'm getting this error message when trying to concat my files using bower concat. What am I doing wrong?

bower.json
{
    "name": "project",
    "description": "project",
    "version": "0.0.1",
    "license": "MIT",
    "private": true,
    "dependencies": {
        "angular": "1.2.18",
        "angular-ui-router": "*",
        "angular-cookie": "~4.0.2",
        "angular-translate": "~2.1.0",
        "angular-translate-loader-static-files": "~2.2.0",
        "modernizr": "~2.8.1",
        "jquery": "1.11.0",
        "bootstrap": "~3.1.1",
        "font-awesome": "~4.1.0",
        "lodash": "~2.4.1"
    }
}
Gruntfile.js
module.exports = function(grunt) {
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        bower_concat: {
            all: {
                dest: 'app/dist/lib.js',
                exclude: [
                    'jquery',
                    'modernizr'
                ],
                dependencies: {
                    'angular-cookie': 'angular',
                    'angular-translate': 'angular',
                    'angular-ui-router': 'angular',
                    'angular-translate-loader-static-files': 'angular-translate'
                },
                bowerOptions: {
                    relative: false
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-bower-concat');
    grunt.registerTask('default', ['bower_concat']);
};

bower_concat does nothing

Hi,
I tried to install bower_concat to make things easy with grunt compilation. I have included the following dependencies in my bower.json:

// [...] usually things above
"devDependencies": {
    "bootstrap-sass": "boostrap-sass#^3.3.7",
    "jquery": "^3.1.1",
    "jquery-ui": "jqueryui#^1.12.1",
    "jqueryui-bootstrap": "^1.0.0",
    "html5shiv": "^3.7.3",
    "respond": "^1.4.2",
    "moment": "^2.15.1",
    "fullcalendar": "^3.0.1",
    "Swiper": "idangerous-swiper#^3.3.1",
    "jquery-validation": "jquery-validate#^1.15.1",
    "slidebars": "^2.0.2",
    "tinymce": "^4.4.3",
    "tinymce-i18n": "^4.0.0",
    "globalize": "^1.1.1"
  }

And my Gruntfile for the bower_concat task looks like this:

bower_concat:
            {
                all:
                {
                    dest:
                    {
                        "js": "web/assets/js/vendors.js",
                        "css": "web/assets/styles/vendors.css"
                    },
                    exclude:
                    [
                        "cldr-data",
                        "cldrjs"
                    ],
                    nonull: true
                }
            },

So, as I understand that task, it should resolve everything based on my bower.json packages. But I actually does nothing.

And another question in this context: Is that issue with the Bootstrap mainFiles configuration in addition to new bower specs fixed now or not? I could not figure it out on the threads below here.

Fatal error: Cannot read property 'canonicalDir' of undefined

From what I can tell, this error occurs when a component appears as a dependency of a direct project dependency (i.e. project depends on 'A' and 'A' depends on 'B' but project does not depend on 'B' directly) and a mainFile is declared via the plugin config. In this case lists.map.dependencies[name] does not return the proper object since it's looking at top-level (direct) dependencies only. This results in findMainFiles failing when it tries to read the meta.canonicalDir property.

A workaround is to include the dependency for which this issue occurs explicitly in your bower.json so it becomes a top level dependency but eventually the plugin should handle this condition.

Azure deployment fails.

Looks like a dependency is failing.

Updating branch 'master'. error: unable to create file node_modules/grunt-bower-concat/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js (No such file or directory) fatal: cannot create directory at 'node_modules/grunt-bower-concat/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/node_modules/proto-list': No such file or directory

D:\Program Files (x86)\Git\bin\git.exe checkout master --force


Make node library

Extract plugin code to a separate node library, use it as dependency here and create Gulp plugin.

  • Remove Grunt API calls from the code.
  • Move as much code as possible to (kinda) lib folder.
  • Create bower-concat node module, move code there and use it here as dependency.

Pull requests are welcome :shipit:

Font files path may not be right after concat

Some bower components may contains font folders, now I have to exclude these components.
For example, font-awesome.
Is there a way to fix this, move fonts to a dist folder after concating css or js?

Concat files that aren't terminated properly, option for separator?

Trying to concat all of these bower packages, but I have a couple that don't terminate correctly (lacking a semicolon). Some of these packages are post-processed, minified JavaScript files. In grunt-concat, I can simply use:

options: {
    separator: ';',
},

But I'm not seeing an option to do that here. Is there a workaround with the callback or is this on the roadmap?

Create sourcemap for concatenated files

Any chance to integrate grunt-concat-sourcemap so you can see in which original file an error occurred? It's very helpful during development.

Thanks a lot!

Correct way to handle modules with missing end semicolon

What is the correct way to deal with a module that doesn't end with a semi-colon? mapbox.js doesn't have one in either the source or minified versions it distributes, which causes whatever follows to throw 'cannot find module' exception with bower_concat.

It seems like they simply advise people with problems to 'use better build tools'.

order and exclusions

Hi all

Is like to use this plugin to handle a very specific implementation.

We are migrating from a script based concat process to grunt. As a consequence we need to be very specific about what files are included and in what order.

I have spent a few hours today trying to use the mainFile config item to manage this. However, I have had little success.

I am seeing mainFile being ignored and all .js from a bower component being pulled in.

Ideally I'd like to do something like

"blue-imp-upload" : [ "!js/*.js", "js/jquery-blue-imp.js"]

However it seems that everything in js/ is being pulled in. I note from the source that this is not possible.

I'd hope that the dependencies would also be handled though given that I'm also using componentjs I'd like to specifically ignore some of the dependencies based on specific files rather than modules.

A gist with my config can be found at
https://gist.githubusercontent.com/mteichtahl/3a600764e81efc7a4039/raw/eb68d917fd3d8530acc1a909ffba19b10c965e1a/bower_concat.js

Any guidance or insight would be appreciated.

Font support

Hi, Is font packaging still supported? Unable to build font awesome without manually adding the fonts, tried fontDest and adding 'fonts' to 'dest' object with no success.

Many Thanks

Custom bootstrap

I would like to use grunt-bower-concat to build custom vendor javascript file but I am always get error:

> grunt bower_concat
Running "bower_concat:js" (bower_concat) task
Fatal error: Arguments to path.join must be strings

My grunt config is:

bower_concat: {
      js: {
        options: {
          separator : ';'
        },
        dest: 'js/vendor.js',
        dependencies: {
          'bootstrap': 'jquery'
        },
        include: [
          'jquery',
          'bootstrap'
        ],
        mainFiles: {
          bootstrap: [
            "js/transition.js",
            .......
          ]
        }
      }
    }

Everithing is fine when I am commented mainFiles.bootstrap.

Does it Support CSS

I am working on a project which includes lots of dependencies as bower components, each of these components will have CSS and JS

I was trying to write a plugin and see that you have exactly what i wanted, but i guess you only support JS, do you support CSS too?

multiple source/dest concats?

Something like:

bower_concat: {
  js_header: {
    include: [
      'package_1',
      'package_2'
      ],
    dest: 'build/_bower_header.js',
  },
  js_footer: {
    include: [
      'package_3',
      'package_4'
      ],
    dest: 'build/_bower_footer.js',
  },
  js_other: {
    include: [
      'package_1',
      'package_4'
      ],
    dest: 'build/_bower_other.js',
  },
}

task should only be run if needed

The bower_concat task is always executed, even if nothing changed in the bower_components directory. To speed up builds it would be nice, if the task checks if the dest file is older than the newest file in bower_components.

This could be achieved easily if grunt-bower-concat would play nice together with grunt-newer, but it isn't, because grunt-newer would call grunt-bower-concat with an object like { files: [ { src: [Object], dest: 'build/vendor.js', orig: [Object] } ] } instead of the awaited object like { dest: 'build/tmp/vendor.js' }.

Here's an example config with grunt-newer:

grunt.initConfig( {
    bower_concat: {
        build: {
            dest: 'build/vendor.js',
        }
    },
    concat: {
        build: {
            src: [ 'build/vendor.js', 'src/app.js' ]
            dest: 'build/all.js',
        }
    },
    uglify: {
        build: {
            files: {
                'build/main.min.js': [ 'build/main.js' ],
            },
        },
    },
} );

grunt.loadNpmTasks( 'grunt-bower-concat' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-newer' );

grunt.registerTask( 'build:js', [
    'newer:bower_concat:build', // concat all third party dependencies
    'concat:build',             // concat third party stuff and our own JS
    'uglify:build',             // minify everything
] );

Is there a way to change the working directory?

Is there a way to change the working directory for where grunt-bower-concat looks for the .bowerc or bower_components ?

My Gruntfile and bower_components are in 2 different places.

I've tried (just for kicks)
expand: true
cwd: 'foo/bar'

Surprisingly it gave me a JavaScript exception (as a warning) when I tried that.
Running "bower_concat:dist" (bower_concat) task
Warning: Cannot call method 'indexOf' of undefined

Include non Bower file

Is there any way to include non bower plugin?
I want to escape creating separate concat task for some plugins which are not available trough Bower.

Path to bower.json

My gruntgile.js is in a diffrent directory from bower.json. Can I somehow specify a path to it?

You should specify "dest" and/or "cssDest" properties in your Gruntfile

I'm trying to use bower_concat. I get this error:

You should specify "dest" and/or "cssDest" properties in your Gruntfile

This is my gruntfile.js:

    // Bower Concat
    bower_concat : {
        css : { 
            cssDest : 'includes/css/bower.css',
            mainFiles : {}
        },
        js  : { 
            dest    : 'includes/js/bower.js', 
            exclude : [ "jquery" ],
            mainFiles :{
            }
        }
    }

In my bower there are those dependencies:

  "dependencies": {
    "jquery-filedrop": "~0.1.0",
    "Jcrop": "^2.0.4",
    "jQuery-contextMenu": "^2.2.0"
  }

What's wrong with this?

Concat both CSS + JS?

I'm trying to use grunt-bower-concat for a pretty simple build system. Everything was going swimmingly until I added a component that contained both CSS and JS (namely https://github.com/vitalets/angular-xeditable).

The bower_concat section of my Gruntfile (.coffee) just has

bower_concat:
  all:
    dest: 'build/components.js'

angular-xeditable has a bower.json file with the following lines:

"main": [
  "dist/css/xeditable.css",
  "dist/js/xeditable.js"
]

I'd like to be able to concatenate the xeditable.css into components.css and xeditable.js into components.js.

It seems like a reasonable solution would be something like

bower_concat:
  all:
    dest:
      js: 'build/components.js'
      css: 'build/components.css'

or

bower_concat:
  js:
    dest: 'build/components.js'
  css:
    dest: 'build/component.css'

I'm fairly new to Grunt and even newer to grunt-bower-concat, so I might be way off base here. Is this something that's in the pipeline? Am I missing something obvious?

EDIT: Replace bootstrap-stylus with angular-xeditable just to avoid any stylus-related confusion.

Font Awesome Doesn't Work

When I use this tool for concatenating Font Awesome's css with the other CSS Bower Packages I've downloaded, it returns an error saying that it could not access the Font Awesome font itself, because it takes the CSS out of it's directory, and the webfont is left behind.

Is there a way I could fix this?

Support any file type

Make it possible to support any file type for example:

filetypes: {
"css" : "dist/main.css",
"js" : "dist/main.js",
"scss" : "src/sass/_bowerdeps.scss"
}

Possibly make the key a regex for file matching.

And not exit with an error when main files of a specific type are not found in a module as happens in the the current version (or add a force option and make it a warning instead of an error that fails the build).

Isolate dependencies

Hello,

I think it would be a nice feature that bower concat could isolate dependencies, some dependencies aren't correctly isolated and sometimes it causes collisions.

Web Components

Umm yea, Web Components are on the horizon. There a basically html files including css and js stored as bower components. I am not happy about storing Web Components on bower but yea, thats how it is actually.

Obviously "grunt-bower-concat" fails at trying to concat these components. Any plans of supporting this in the near future? Im trying to come up with a clean workaround today, basically hiding web components from bower-concat and treat them separately via another task or something.

v0.5.0 doesn't work without includeDev = true

The new version doesn't do anything if includeDev is not set to true.

When includeDev = false

# grunt -v bower_concat

Running "bower_concat" task

Running "bower_concat:all" (bower_concat) task
Verifying property bower_concat.all exists in config...OK
Files: -> assets/js/plugins/bower.js
Options: separator="\n"

Scripts: -> assets/js/plugins/bower.js

Styles: -> assets/css/plugins/bower.css

When includeDev = true

[...]
Finding main file for timepicker-jqueryui...
Considering the only JS file in a component’s folder as a main file: /Users/Zeno/Sites/Graffino/Box/TravelKeys/bower_components/timepicker-jqueryui/timepicker.js
Reading /Users/Zeno/Sites/Graffino/Box/TravelKeys/bower_components/timepicker-jqueryui/timepicker.js...OK

Finding main file for video.js...
Main file was specified in bower.json: /Users/Zeno/Sites/Graffino/Box/TravelKeys/bower_components/video.js/dist/video-js/video.js,/Users/Zeno/Sites/Graffino/Box/TravelKeys/bower_components/video.js/dist/video-js/video-js.css
Reading /Users/Zeno/Sites/Graffino/Box/TravelKeys/bower_components/video.js/dist/video-js/video.js...OK
Reading /Users/Zeno/Sites/Graffino/Box/TravelKeys/bower_components/video.js/dist/video-js/video-js.css...OK

Scripts: -> assets/js/plugins/bower.js
  ./bower_components/jquery/dist/jquery.js [jquery] - 241.79 kB
  ./bower_components/h5Validate/jquery.h5validate.js [h5Validate] - 19.77 kB
  ./bower_components/nouislider/distribute/jquery.nouislider.all.js [nouislider] - 57.29 kB
  ./bower_components/fancybox/source/jquery.fancybox.js [fancybox] - 47.56 kB
  ./bower_components/browser-update/browser-update.js [browser-update] - 16.07 kB
  ./bower_components/matchHeight/jquery.matchHeight-min.js [matchHeight] - 2.94 kB
  ./bower_components/modernizr/modernizr.js [modernizr] - 50.15 kB
  ./bower_components/select2/select2.js [select2] - 145.05 kB
  ./bower_components/slick.js/slick/slick.js [slick.js] - 70.25 kB
  ./bower_components/srcset-poly/build/srcset.js [srcset-poly] - 24.43 kB
  ./bower_components/timepicker-jqueryui/timepicker.js [timepicker-jqueryui] - 99.08 kB
  ./bower_components/video.js/dist/video-js/video.js [video.js] - 115 kB

Styles: -> assets/css/plugins/bower.css
  ./bower_components/nouislider/distribute/jquery.nouislider.min.css [nouislider] - 2.05 kB
  ./bower_components/fancybox/source/jquery.fancybox.css [fancybox] - 4.78 kB
  ./bower_components/select2/select2.css [select2] - 19 kB
  ./bower_components/slick.js/slick/slick.css [slick.js] - 1.68 kB
  ./bower_components/video.js/dist/video-js/video-js.css [video.js] - 27.36 kB

Writing assets/js/plugins/bower.js...OK
File assets/js/plugins/bower.js created.
Writing assets/css/plugins/bower.css...OK
File assets/css/plugins/bower.css created.

mainFiles() seems to be ignored

Greetings,

I have got bower_concat up and running for the most part- but the one thing that I just can't seem to get to work is the mainFiles() option. I have tried placing the options in different orders, tried the various ways of adding the files in it, but to no avail. Have tried multiple plugins and files, but it doesn't seem to help.

I have supplied my Gruntfile over at Stackoverflow: http://stackoverflow.com/questions/32946688/grunt-grunt-bower-concat-ignoring-mainfiles-option

Is this just me being a noob, or..?

can not concat file

I found it can not concat files ,because the bower.command.list has not event "data" but "end"

Failures with circular dependency

grunt-bower-concat fails if it detects a circular dependency between two modules. Bower has supported circular dependencies for a few releases and some of the Polymer core components have circular dependencies.

Even though I'm not using grunt-bower-concat with those Polymer core components the error : Circular reference detected is thrown from resolveDependencyGraph.

As a workaround is there a way to exclude certain modules from the dependency checks? I only include: a small number of modules - and not the polymer ones.

Fatal error: Arguments to path.join must be strings

Hi,

I'm not sure if this is an issue with this plugin or user error, but I get the following error:

Fatal error: Arguments to path.join must be strings

Here's the config:

...

    bower_concat: {
      all: {
        dest: 'bower.js',
        exclude: [
          'bourbon',
          'neat',
          'normalize-scss',
          'sass-toolkit'
        ],
        bowerOptions: {
          relative: false
        },
        mainFiles: {
          'headroom.js': 'jQuery.headroom.js'
        }
      }
    },

...

My package.json:

{
  "engines": {
    "node": ">= 0.10.0"
  },
  "devDependencies": {
    "bower": "~1.3.1",
    "grunt": "~0.4.2",
    "grunt-autoprefixer": "~0.7.2",
    "grunt-bower-concat": "~0.2.4",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-nodeunit": "~0.2.2",
    "grunt-contrib-sass": "~0.7.3",
    "grunt-contrib-uglify": "~0.2.7",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-includes": "^0.4.4",
    "matchdep": "~0.3.0"
  }
}

node is v0.10.28

Any ideas?

Thanks, LM.

Doesn't work with grunt-newer

If destination file doesn't exist and bower_concat is run with "newer:" it would crash with:

Unable to process task.
Warning: Required config property "bower_concat.munit.dest" missing. Use --force to continue.

To make it work with "newer:" to begin with, i had to add "src" field, which is not a problem, but i'm not sure if there's a good workaround for that crash if dest file doesn't exist.

Include own bower.json

I got a bower.json file in my project root which declares my dependencies.
It has some mainFiles, too.

If i use bower-concat the mainFiles are not used (only the ones from the dependencies).

Usemin has an option for using the own file.
Is there some for bower-concat, too?

Blank CSS File

Using the following in my gruntfile.js

bower_concat: {
        all: {
            dest: 'public/js/vendors.js',
            cssDest: 'public/css/vendors.css',
            include: [
                'jquery',
                'bootstrap'
            ]
        }
    },

The bootstrap directory has the bower.json file and lists the main files. The vendors.js file is fine, just nothing for vendors.css. I've also attempted the mainFiles options.

Don't find components installed in a subdirectory

Hello,

I installed my bower components under "vendor/components" (defined in my .bowerrc) but bower_concat fails to find main files. Though, bower sees them at the right place (bower list -p).

If I move them to "vendor", or any single directory, and change my .bowerrc accordingly it works fine.

Bug or I misunderstood something ?

Thanks

grunt bower_concat is not working on jpillora/jquery.rest

bower.json

{
  "name": "django",
  "description": "project dependencies",
  "main": "bower.json",
  "moduleType": [],
  "license": "MIT",
  "homepage": "",
  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "assets/components",
    "test",
    "tests"
  ],
  "dependencies": {
    "alertify.js": "alertifyjs#~1.0.8",
    "bootstrap-table": "~1.10.1",
    "bootstrap": "~3.3.6",
    "js-cookie": "~2.1.0",
    "underscore": "~1.8.3",
    "string": "stringjs#^3.3.1",
    "jquery": "^2.2.1",
    "jquery-validation": "^1.15.0",
    "jpillora/jquery.rest": "jquery.rest#^1.0.2"
  }
}

bower_concat config inside Gruntfile.js

bower_concat: {
      all: {
        // where to put assembled files
        dest: {
          'js': '<%= globalConfig.assets.dist %>/bower.js',
          'css': '<%= globalConfig.assets.dist %>/bower.css'
        },
        // define dependencies here, so the concatenation happens
        // in correct order
        dependencies: {
          'underscore': 'jquery',
          'alertify.js': 'jquery',
          'bootstrap': 'jquery',
          'jquery.validate.js': 'jquery',
          'jpillora/jquery.rest': 'jquery',
          'bootstrap-table': ['jquery', 'bootstrap']
        },
        // in some cases bower_concat gets bower packages that do
        // not properly define their distr folders/files
        // we can fix it by doing it here
        mainFiles: {
          'bootstrap': [
            'dist/css/bootstrap.css',
            'dist/js/bootstrap.js'
          ],
          'alertify.js': [
            'dist/js/alertify.js',
            'dist/css/alertify.css'
          ],
          'jpillora/jquery.rest': [
            'dist/1/jquery.rest.js'
          ]
        }
      }
    },

so when I'm running grunt bower_concat:all all is assembled except that jquery.rest file.

jquery.rest bower.json

{
  "name": "jpillora/jquery.rest",
  "version": "1.0.2",
  "main": "dist/1/jquery.rest.js",
  "description": "A jQuery plugin for easy consumption of REST APIs",
  "license": "MIT",
  "ignore": [
    "*",
    "!bower.json",
    "!dist/1/jquery.rest.js",
    "!dist/1/jquery.rest.min.js"
  ],
  "dependencies": {},
  "devDependencies": {}
}
it's installed in

(django) [dmitry@DmitryPC django]$ tree -L 4 assets/components/jpillora/
assets/components/jpillora/
└── jquery.rest
    ├── bower.json
    └── dist
        └── 1
            ├── jquery.rest.js
            └── jquery.rest.min.js

Project status, ownership, etc.

grunt-bower-concat still has quite a lot of uses (10 000 downloads per month) but I have no time and will to maintain it. And I don’t use Grunt or Bower for a long time. I don’t even check new issues here anymore.

I’ll be happy to add more people as contributors or transfer ownership if anyone is interested.

Related issue at Grunt repo.

Offline mode?

Hi,

When I don't have a working internet connection, the build fails with

Fatal error: Failed to execute "git ls-remote --tags --heads git://github.com/mbostock/d3.git", exit code of #128

I tried to use the --offline flag as a compile option, as follows:

bowerOptions:
    "offline": true

but it does not seem to have an effect.

(Running

grunt bower_concat --offline

does seem to work as intended.)

Any ideas? Thanks!

Does bower_concat actually read from bower.json to find the main files?

I ran into an issue where this task wont find the main files, and when it tries to run the method findMainFiles, the method does not properly combine paths when trying to guess the main file locations. On the first line of that method, I added the following line:

var component = (component.substr(0,bower.config.cwd.length) === bower.config.cwd)
    ?component.substr(bower.config.cwd.length)
    :component;

This was because the component path was coming in with the bower cwd already prepended to it, and then when the join was called, it mashed the two together and came up with something nonsensical. Also, it appears as though the main file path is also appended to the end of the component as well. So I'm not certain where the corruption of the component var is coming from, as it seems this should only be the local path to the folder of the component, but it's happening in my build.

This does not appear to be an effective and complete fix. As soon as I ran it, it got through d3, ember-data, ember-mocha-adapter, flying-focus, and then failed on handlebars. I'm still working to debug why the last error is happening, but I'm extra baffled when looking for the portion of this grunt task that references bower.json because i see nothing that looks to access and decode that information to utilize it as would be expected.

Use bower.json for package inclusion

I'm using bower concat version 1.0.0 and it seems to be quite primitive at how it includes the components. My projects use a shared bower_components folder and there are project specific components there.

Using grunt_bower_concat without an include parameter the plugin tries to concat every single component it finds inside bower_components. It also tries to include components not specified in bower.json file.

I think it should by default only concat components specified in bower.json and if it can't find one it should use current behaviour as a fallback.

Meanwhile one can simply require the bower.json and use the keys in the include parameter like so:

var bower_file = require('./bower.json');
var bower_components = Object.keys(bower_file.dependencies);

...

bower_concat: {
  all: {
    include: bower_components
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.