javascript – 如何在sails.js中使用.less文件?

我正在阅读 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';

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...