将 Twitter Bootstrap 3 RC1 与 Meteor 结合使用 [英] Use Twitter Bootstrap 3 RC1 with Meteor

查看:41
本文介绍了将 Twitter Bootstrap 3 RC1 与 Meteor 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将最新的 Twitter Bootstrap 3 RC1 与 Meteor 一起使用.我尝试使用 bower 安装它,但 Meteor 由于引导程序包(_includes 目录)中包含一些 HTML 或 JS 而引发错误.我知道流星有一个 bootstrap 包,但这是 Bootstrap 2.3.

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.

我想知道是否有办法忽略某些文件,这样 Meteor 就不会尝试提供这些文件,或者有其他方法来解决这个问题.

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.

推荐答案

现在这是我的解决方案,灵感来自 这个答案:

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

我使用以下 .bowerrc 配置使用 bower 安装 Bootstrap:

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

{
     "directory": "public/bower_components"
}

从这里开始,您可以通过将 Bootstrap 直接包含在您的 <head> 中来使用它,如下所示:

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"/>

或者你可以像这样在你的 less 文件中使用它

Or you can use it in your less files like this

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

感谢@majodev 的帮助.我认为 bootstrap3-less 很好,但是通过使用它,我们引入了该软件包开发人员更新到最新 Bootstrap 版本的另一个依赖项.通过使用 bower,我们知道我们将始终拥有可用的最新版本的引导程序,或者任何版本的引导程序这是我们想要的.

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.

2013 年 8 月 9 日更新:

要使用 bootstrap.js,当前的解决方法是创建一个调用 bootstrap.js 文件的包.我是这样做的:

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

packages

packages
└── bootstrap
    └── package.js

然后在 package.js 中,声明您要包含的 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');
});

这篇关于将 Twitter Bootstrap 3 RC1 与 Meteor 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆