├── README.md ├── .gitignore ├── .npmignore ├── package.json ├── index.js └── LICENSE.md /README.md: -------------------------------------------------------------------------------- 1 | # fis-parser-less 2 | 3 | A parser for fis to compile less file. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | node_modules/ 3 | 4 | .DS_Store 5 | *.db 6 | *.bak 7 | *.tmp 8 | *.cmd 9 | ~* 10 | 11 | upload.py -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.settings 3 | /.project 4 | /.gitignore 5 | /node_modules 6 | /test 7 | /.tmp 8 | 9 | .DS_Store 10 | 11 | *.db 12 | *.bak 13 | *.tmp 14 | *.cmd 15 | ~* 16 | 17 | upload.py -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "fis-parser-less-2.x", 3 | "description" : "A parser for fis to compile less(v2.x) file.", 4 | "version" : "0.1.3", 5 | "author" : "FIS Team ", 6 | "homepage" : "https://github.com/fouber/fis-parser-less", 7 | "keywords": [ "fis", "less" ], 8 | "license": "MIT", 9 | "main" : "index.js", 10 | "engines" : { 11 | "node" : ">= 0.8.0" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/fouber/fis-parser-less-2.x" 16 | }, 17 | "scripts" : {}, 18 | "dependencies" : { 19 | "less" : "2.5.0" 20 | } 21 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * fis 3 | * http://fis.baidu.com/ 4 | */ 5 | 6 | 'use strict'; 7 | 8 | var less = require('less'); 9 | var root = fis.project.getProjectPath(); 10 | 11 | module.exports = function(content, file, conf){ 12 | 13 | conf.paths = [ file.dirname, root ]; 14 | conf.syncImport = true; 15 | conf.relativeUrls = true; 16 | 17 | less.render(content, conf, function (err, result) { 18 | if (err) { 19 | throw err; 20 | return; 21 | } 22 | content = result.css; 23 | result.imports.forEach(function (path) { 24 | file.cache.addDeps(path); 25 | }); 26 | }); 27 | 28 | return content; 29 | }; 30 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 baidu.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------