• This repository has been archived on 11/Oct/2021
  • Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[DEPRECATED] Use bower packages in your Meteor app

Bower for Meteor

deprecated

This package is deprecated in favor of Meteor 1.3+ NPM support and we recommend that you migrate your existing applications using this bower package to Meteor 1.3 NPM. The new solution will be more robust and supported by MDG in the long run.


This package is broken in Meteor 1.3 but is should still work fine on Meteor 1.2 and below. Bower.io is a popular repository of client-side JavaScript libraries.

##Install to your meteor app first using

meteor add mquandalle:bower

Usage

To use it in your meteor application, create a bower.json file:

{
  "name": "my-app",
  "version": "0.0.1",
  "dependencies": {
    "select2": "3.4.5",
    "backbone": "1.1.0"
  },
  "private": true
}

If you want to use a bower library at script load time (outside of a Meteor.startup block, template handler, event, etc), you have to place the bower.json file so that it loads first (see [Meteor load order](http://stackoverflow.com/questions/10693113/how-do-i-change-the-order-in- which-meteor-loads-javascript-files)). Take the deepest directory you have inside [project root]/lib/, add a bower directory, and put bower.json there. So for example, if you currently have no directories in lib/, then you can do lib/bower/bower.json, but if your current structure is lib/foo/bar/, then you should do lib/foo/bar/bower/bower.json. Then put a .bowerrc file in the same directory with enough ../s to get back to your project root. For instance with a lib/bower/bower.json it would be:

{
  "directory": "../../.meteor/local/bower"
}

The next time you run meteor, the select2 and backbone libraries will be downloaded, and the appropriate HTML tags to include those libraries will automatically be added to your app. So you can just start using select2 widgets, and styles will be set correctly. (If you're curious just look at the HTML source of a rendered page!) We use the main section of the library's bower.json file to determine which files should be loaded.

If the package you're adding doesn't use the main section: you can choose which files you want by adding an override field to your bower.json as described in #54.

Compare this to just using the bower command, where you need to either manually reference the included files or use something like grunt-bower-install to reference them.

Using bower --save

If you want to use the bower install <package> --save command, you can add this .bowerrc file in the project root directory:

{
  "directory": ".meteor/local/bower"
}

Raw files

If you need to reference the raw files (eg Polymer components in html files), you can set a different directory, eg "public/bower_components", and include those files manually in your <head>.

Limit package scope

Make modernizr only available on the client by setting the arch in your bower.json:

"overrides": {
  "modernizr": {
      "arch": [ "client" ]
    }
}

Other values include [ "server" ] and [ "client", "server" ].

Excluding dependencies

You can ask meteor-bower to ignore a list of dependencies. For instance if you have the Meteor package reactjs:react and the bower package react-bootstrap, and you don't want meteor-bower to include a duplicate copy of react, add an ignoredDependencies array to your bower.json:

{
  "name": "my-app",
  "version": "0.0.1",
  "dependencies": {
    "select2": "3.4.5",
    "react-bootstrap": "~0.16.1"
  },
  "ignoredDependencies": [
    "react"
  ]
}

Multiple package directories

You can also have multiple bower.json files, each paired with a .bowerrc, for instance:

bower.json:
{
  "dependencies": {
    "select2": "3.4.5"
  }
  ...
}
.bowerrc
{
  "directory": ".meteor/local/bower"
}

lib/bower.json:
{
  "dependencies": {
    "polymer": "~0.5.1"
  }
  ...
}
lib/.bowerrc:
{
  "directory": "../public/bower_components"
}

Contributing

Contributions are very welcome, whether it is a bug report or a PR with a fix or enhancement.

License

This code is published under the MIT license.

More Repositories

1

meteor-jade

The Jade template engine for Meteor/Blaze
JavaScript
307
star
2

meteor-stylus

Expressive, dynamic, robust CSS
JavaScript
58
star
3

mesaidesvelo

Découvrez les aides à l’achat d’un vélo
Svelte
57
star
4

meteor-harmony

[DEPRECATED] Javascript Harmony for Meteor
JavaScript
52
star
5

apprendre-meteor

Le cours en français pour apprendre Meteor
24
star
6

chronos

Trusted timestamp on top of ethereum
JavaScript
11
star
7

ethereum-rust

Ethereum client implemented in Rust
Rust
8
star
8

meteor-promisify-core

Replace callbacks by promises in Meteor core APIs
JavaScript
7
star
9

ethereum-cosign

Multisigs for Ethereum
CoffeeScript
7
star
10

meteor-minifiers

Remove the code that doesn't need to be send to a Meteor client.
JavaScript
6
star
11

blaze-autofocus

Support autofocus attribute in Blaze templates
JavaScript
5
star
12

tracker-mobx-bridge

JavaScript
4
star
13

meteor-collection-mutations

A solution for the allow/deny vs methods dilemma
JavaScript
4
star
14

meteor-ismobile

Add a Meteor.isMobile boolean variable
JavaScript
4
star
15

publicodes-compiled

publicodes-compiled
Svelte
3
star
16

meteor-jeet

A grid sytem for SASS or Stylus
JavaScript
3
star
17

meteor-slugify

Remove all special characters from a string.
JavaScript
2
star
18

meteor-macros

Macros for Meteor
JavaScript
2
star
19

optirem

JavaScript
2
star
20

smartBudget

CSS
1
star
21

new-sort-lib-for-libreboard

Try to replace jQuery UI by something better to handle card, list, labels sorting in LibreBoard
JavaScript
1
star
22

count-publicodes-lines

JavaScript
1
star
23

meteor-perfect-scrollbar

JavaScript
1
star
24

meteor-jquery-textcomplete

A thin wrapper around jquery-textcomplete for Meteor
JavaScript
1
star
25

meteor-jquery-ui-drag-drop-sort

A meteor wrapper for jquery-ui a custom build
JavaScript
1
star