Use Twitter Bootstrap 3 RC1 with Meteor

不想你离开。 提交于 2019-12-21 06:45:08

问题


I am trying to use the latest Twitter Bootstrap 3 RC1 with Meteor. I tried to install it using bower, but Meteor threw an error because of some HTML or JS included in the bootstrap package (the _includes directory). I am aware that meteor has a bootstrap package, however this is Bootstrap 2.3.

I wonder if there's a way to either ignore certain files so that Meteor will not try and serve these files, or other way to get around this.


回答1:


Have you tried the custom atmosphere package bootstrap3-less?

ad. question: I know that the test subdirectory will be ignored on clients/server, but that's just an awful place. Have you tried putting it into lib/external? The Unofficial Meteor FAQ might also be a good starting point.




回答2:


For now here's my solution, as inspired by this answer:

I install Bootstrap with bower with the following .bowerrc config:

{
     "directory": "public/bower_components"
}

From here, you can use Bootstrap by either include it directly in your <head> like this:

<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"/>

Or you can use it in your less files like this

@import "public/bower_components/bootstrap/less/bootstrap.less";

Thanks to @majodev for his help. I think bootstrap3-less is nice, but by using it we're introducing another dependency of that package's developer updating to the latest Bootstrap releases. By using bower, we know we will always have the latest version of bootstrap available, or whatever version of it we want.

Update 8/9/13:

To use bootstrap.js, the current workaround is to create a package that calls the bootstrap.js file. Here's how I do it:

Create a bootstrap directory in packages

packages
└── bootstrap
    └── package.js

Then in package.js, declare the js files you'd like to include, for example:

// package.js

Package.describe({
    summary: "Load bootstrap script."
});

Package.on_use(function(api) {
    api.add_files(['../../public/bower_components/bootstrap/dist/js/bootstrap.min.js'], 'client');
});



回答3:


One should NOT use any more a specific method or package to add Bootstrap features to Meteor as Bootstrap is now officially released as a Meteor package.

See 3.3.4 changelog http://blog.getbootstrap.com/2015/03/16/bootstrap-3-3-4-released/

Bootstrap is now also available as a Meteor package in the Atmosphere package index.



来源:https://stackoverflow.com/questions/18110976/use-twitter-bootstrap-3-rc1-with-meteor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!