Use Bootstrap Project Manager to manage multiple Twitter Bootstrap projects without having to maintain multiple versions of Bootstrap.
If you gon't already have Grunt installed, do this.
$ npm install -g grunt-cli
Clone Bootstrap Project Manager.
$ git clone https://github.com/cdcarson/bootstrap-project-manager.git
Change into the directory.
$ cd bootstrap-project-manager
Initialize and update the Bootstrap submodule.
$ git submodule init
$ git submodule update
Install the dependencies.
$ npm install
All commands take the the following form:
$ grunt <command>:<project-name>
$ grunt init:foobar
This command initializes a new project. It:
- Creates the
bootstrap-roject-manger/projects
folder if one does not exist (i.e. this is your first project.) This folder is.gitignore
'd, and is where your projects are stored. - Under that directory, it creates the project folder named with what you provided to the command, in this case
foobar
. - Copies the Bootstrap fonts from
boostrap/fonts
intofoobar/assets/fonts
. See update-fonts. - Concats and minifies the js
boostrap/js
intofoobar/assets/js
. See update-bootstrap-js. - Creates
less/style.less
. This file contains one line:@import "../../../bootstrap/less/bootstrap";
. That file is compiled and minified. See update-css. - Creates a
project.json
file that tracks versions and where you can add additional targets. See bump.
The file layout:
- bootstrap-project-manager
- projects
- foobar
- assets
- css
- style.css
- style.min.css
- fonts
- glyphicons-halflings-regular.eot
- glyphicons-halflings-regular.svg
- glyphicons-halflings-regular.ttf
- glyphicons-halflings-regular.woff
- js
- bootstrap.js
- bootstrap.min.js
- less
- style.less
- project.json
$ grunt update-fonts:foobar
- Freshly copies the Bootstrap fonts from
bootstrap/fonts
tofoobar/assets/fonts
. Note that other font files and directories infoobar/assets/fonts
are not overwritten. - For each target you've defined:
- Cleans the
target/assets/fonts
directory withclean
. This means that fonts you've added to the target without adding them tofoobar/assets/fonts
will be deleted. - Copies everything from
foobar/assets/fonts
totarget/assets/fonts
- Cleans the
- Bumps the version number if called directly from the command line
$ grunt update-bootstrap-js:foobar
- Creates fresh copies of
bootstrap.js
andbootstrap.min.js
infoobar/assets/js
from the bootstrap source code usingconcat
anduglify
. Note that other js files and directories infoobar/assets/js
are not overwritten. - For each target you've defined:
- Cleans the
target/assets/js
directory withclean
. This means that anything you've added to the target without adding them tofoobar/assets/js
will be deleted. - Copies everything from
foobar/assets/js
totarget/assets/js
- Cleans the
- Bumps the version number if called directly from the command line
$ grunt update-css:foobar
- Compiles
less/style.less
intofoobar/assets/css/style.css
andfoobar/assets/css/style.min.css
usingrecess
. Note that other css files and directories infoobar/assets/css
are not overwritten. - The
less/
directory is where you'll make your style changes. All the files in this directory are watched by thewatcher
command below; but onlyless/style.less
is compiled That means that you have to@import
the LESS files you want intostyle.less
. - For each target you've defined:
- Cleans the
target/assets/css
directory withclean
. This means that anything you've added to the target without adding them tofoobar/assets/css
will be deleted. - Copies everything from
foobar/assets/css
totarget/assets/css
- Cleans the
- Bumps the version number if called directly from the command line
$ grunt bump:foobar
- Bumps the least significant version number in
project.json
.
$ grunt watch-css:foobar
- Calls update-css once, then uses
watch
to watch theassets/less
directory for changes. update-css is called every time a less file changes. - Bumps the version number every time.
- Do control-c to remove the watch.
project.json
looks like this:
{
"name": "foobar",
"description": "New project. Put your description here.",
"version": "0.0.4",
"targets": []
}
You can change the description and version number. The project name should always be the same as the directory name.
Additionally, you can add use the targets
array to pass additional file paths to be updated when update-fonts, update-bootstrap-js, or update-css are called:
{
"name": "foobar",
"description": "New project. Put your description here.",
"version": "0.0.4",
"targets": [
"/Users/chris/dev/another",
"/Users/chris/dev/something",
]
}
This will copy assets/css
, assets/fonts
and assets/js
into both /Users/chris/dev/another
and /Users/chris/dev/something
every time the project changes.