[英]How use .less files in sails.js?
我正在閱讀http://sailsjs.org/#!documentation/assets但我不知道如何使用.less文件。
我把資產/鏈接器/樣式/中的vairables.less和bootswatch.less都放了
我希望grunt會編譯這兩個文件,但它沒有,我在瀏覽器控制台中遇到錯誤:
GET http://localhost:5000/linker/styles/bootstrap-responsive.css 404 (Not Found) (index):14
GET http://localhost:5000/linker/styles/bootstrap.css 404 (Not Found) (index):15
GET http://localhost:5000/linker/js/jquery.js 404 (Not Found) (index):29
GET http://localhost:5000/linker/js/socket.io.js 404 (Not Found) (index):30
GET http://localhost:5000/linker/js/sails.io.js 404 (Not Found) (index):31
GET http://localhost:5000/linker/js/app.js 404 (Not Found) (index):32
GET http://localhost:5000/linker/js/bootstrap.js 404 (Not Found)
如果我刪除兩個.less文件它可以正常工作。 我在這里錯過了什么?
如果您使用的是最新版本的Sails.js,那么將.less文件放在assets / styles目錄下,並將其包含在importer.less文件中,如下所示:
/**
* importer.less
*
* By default, new Sails projects are configured to compile this file
* from LESS to CSS. Unlike CSS files, LESS files are not compiled and
* included automatically unless they are imported below.
*
* The LESS files imported below are compiled and included in the order
* they are listed. Mixins, variables, etc. should be imported first
* so that they can be accessed by subsequent LESS stylesheets.
*
* (Just like the rest of the asset pipeline bundled in Sails, you can
* always omit, customize, or replace this behavior with SASS, SCSS,
* or any other Grunt tasks you like.)
*/
// For example:
//
// @import 'variables/colors.less';
// @import 'mixins/foo.less';
// @import 'mixins/bar.less';
// @import 'mixins/baz.less';
//
// @import 'styleguide.less';
// @import 'pages/login.less';
// @import 'pages/signup.less';
//
// etc.
@import 'custom.less';
我決定不使用sails默認導入器。 主要是因為我發現它很糟糕,太多基於配置超過約定。 所以我根據約定優於配置創建了自己的動態資源加載器。
基本上,在我的,沒有更多的事情要做,資產將根據控制器,控制器動作,主題和使用的布局來應用。 它仍然使用LESS。
這是一個基於風帆0.10.5
的簡單項目: https : //github.com/Vadorequest/sails-dynamic-assets
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.