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

前端之家收集整理的这篇文章主要介绍了javascript – 如何在sails.js中使用.less文件?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在阅读 http://sailsjs.org/#!documentation/assets,但我不知道如何使用.less文件.

我把资产/链接器/样式/中的vairables.less和bootswatch.less都放了

我希望grunt会编译这两个文件,但它没有,我在浏览器控制台中遇到错误

  1. GET http://localhost:5000/linker/styles/bootstrap-responsive.css 404 (Not Found) (index):14
  2. GET http://localhost:5000/linker/styles/bootstrap.css 404 (Not Found) (index):15
  3. GET http://localhost:5000/linker/js/jquery.js 404 (Not Found) (index):29
  4. GET http://localhost:5000/linker/js/socket.io.js 404 (Not Found) (index):30
  5. GET http://localhost:5000/linker/js/sails.io.js 404 (Not Found) (index):31
  6. GET http://localhost:5000/linker/js/app.js 404 (Not Found) (index):32
  7. GET http://localhost:5000/linker/js/bootstrap.js 404 (Not Found)

如果我删除两个.less文件,它可以正常工作.
我在这里想念的是什么?

解决方法

如果您使用的是最新版本的Sails.js,则将.less文件放在assets / styles目录下,并将其包含在importer.less文件中,如下所示:
  1. /**
  2. * importer.less
  3. *
  4. * By default,new Sails projects are configured to compile this file
  5. * from LESS to CSS. Unlike CSS files,LESS files are not compiled and
  6. * included automatically unless they are imported below.
  7. *
  8. * The LESS files imported below are compiled and included in the order
  9. * they are listed. Mixins,variables,etc. should be imported first
  10. * so that they can be accessed by subsequent LESS stylesheets.
  11. *
  12. * (Just like the rest of the asset pipeline bundled in Sails,you can
  13. * always omit,customize,or replace this behavior with SASS,SCSS,* or any other Grunt tasks you like.)
  14. */
  15.  
  16.  
  17.  
  18. // For example:
  19. //
  20. // @import 'variables/colors.less';
  21. // @import 'mixins/foo.less';
  22. // @import 'mixins/bar.less';
  23. // @import 'mixins/baz.less';
  24. //
  25. // @import 'styleguide.less';
  26. // @import 'pages/login.less';
  27. // @import 'pages/signup.less';
  28. //
  29. // etc.
  30. @import 'custom.less';

猜你在找的JavaScript相关文章