如何在sails 0.9中提供bootstrap模板?

我想知道如何通过较新的帆版本来提供引导模板。 我应该更新JS的链接到其他东西。 我试图移动资产文件夹中的JS和图像,但JavaScript没有工作。 在这个话题上帆的文件是非常贫穷的。 谁能告诉一个简单的方法来整合它。 提前致谢

Sails 0.9.x已经开始使用Grunt来处理资产。 这使您可以执行许多不同types的预编译和资产处理。 默认情况下,自动资产注入您的视图和布局不可用。

我们添加了一个标志,您可以在生成一个新的sails项目时添加这个标签,这个项目将在资产文件夹中创build一个文件夹,并自动将任何文件注入到index.html或布局文件中。 这只能用于开发。

sails new <project name> --linker

现在,您的资产文件夹下会有一个标题为linker文件夹,您可以放置​​文件以使其自动链接。 它还会添加一些标签到你的index.html文件和你的布局文件,以知道在哪里注入各种JS,CSS和模板。

您可以在这里阅读更多: 帆维基 – 资产

如果您正在处理已创build的项目,则可以手动创build以下文件结构:

 assets/ linker/ js/ styles/ templates/ 

您还需要将以下标记添加到您的视图中:

 <!--SCRIPTS--> All .js files in assets/linker/js will be included here In production mode, they will all be concatenated and minified <!--SCRIPTS END--> <!--STYLES--> All .css files in assets/linker/styles (including automatically compile ones from LESS) will be included here In production mode, they will all be concatenated and minified <!--STYLES END--> <!--TEMPLATES--> All *.html files will be compiled as JST templates and included here. <!--TEMPLATES END--> 

因此,要使用引导程序并将文件自动添加到您的页面,您将把bootstrap.js文件放置到assets/linker/js和bootstrap.css文件中,放入assets/linker/css

在生产中,您将需要编辑gruntfile以将所有css和js编译为单个文件,并在view / layout / index.html中手动链接它们。

汉字有一个问题。 缩小的css文件的目标是/.temp/public/min/production.css,字体必须在/.temp/public/fonts/中。 然后,您必须将assets / linker / fonts /中的字体文件夹复制到/.temp/public/fonts/。

您必须将其添加到copy.dev.files数组内的Gruntfile中:

 { expand: true, cwd: './assets/linker/fonts', src: ['**/*'], dest: '.tmp/public/fonts' } 

或者以更一般的方式:

 { expand: true, cwd: './assets', src: ['**/fonts/*'], dest: '.tmp/public/fonts', flatten: true } 

它将在assets下search所有名为fonts文件夹。 使用flatten来避免子文件夹。

干杯,