From 32a6b81d83780446ce71581e403285e99d922aee Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Mon, 7 Jan 2019 10:46:01 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=94=AF=E6=8C=81less=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 43 ++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 50002f9..b04b011 100644 --- a/index.js +++ b/index.js @@ -6,10 +6,6 @@ var postcss = require('postcss') var render = require("./lib/render")(less.ParseTree, less.transformTree); -function isFunction(f){ - return typeof f === 'function'; -} - function LessPlugin() { var cacheInput; @@ -96,8 +92,8 @@ function LessPlugin() { directive: function(directive) { var filename = directive.path - ? directive.path.currentFileInfo.filename - : directive.currentFileInfo.filename; + ? directive.path._fileInfo.filename + : directive._fileInfo.filename; var val, node, nodeTmp = buildNodeObject(filename, directive.index); if(!directive.path) { @@ -152,7 +148,7 @@ function LessPlugin() { if (!(pathSubCnt = path.length)) { continue; } if(i === 0) { - tmpObj = buildNodeObject(ruleset.selectors[0].elements[0].currentFileInfo.filename, ruleset.selectors[0].elements[0].index); + tmpObj = buildNodeObject(ruleset.selectors[0].elements[0]._fileInfo.filename, ruleset.selectors[0].elements[0].index); node = { type: "rule" , nodes: [] @@ -177,7 +173,7 @@ function LessPlugin() { for (i = 0; i < ruleset.selectors.length; i++) { selector = ruleset.selectors[i]; if(i === 0) { - tmpObj = buildNodeObject(selector.elements[0].currentFileInfo.filename, selector.elements[0].index); + tmpObj = buildNodeObject(selector.elements[0]._fileInfo.filename, selector.elements[0].index); node = { type: "rule" , nodes: [] @@ -201,7 +197,7 @@ function LessPlugin() { } // PostCSS "decl" , rule: function(rule) { - var node, tmpObj = buildNodeObject(rule.currentFileInfo.filename, rule.index); + var node, tmpObj = buildNodeObject(rule._fileInfo.filename, rule.index); var evalValue = getObject(rule.value, true); node = { @@ -229,7 +225,7 @@ function LessPlugin() { } , comment: function(comment) { - var node, tmpObj = buildNodeObject(comment.currentFileInfo.filename, comment.index); + var node, tmpObj = buildNodeObject(comment._fileInfo.filename, comment.index); node = { type: "comment" @@ -259,14 +255,14 @@ function LessPlugin() { } // a.k.a. PostCSS "decl" - else if(val instanceof less.tree.Rule) { + else if(val instanceof less.tree.Declaration) { container.append(process.rule(val)); } else if(val instanceof less.tree.Comment) { container.append(process.comment(val)); } // a.k.a. PostCSS "atrule" - else if(val instanceof less.tree.Directive) { + else if(val instanceof less.tree.AtRule) { container.append(process.directive(val)); } else if(val instanceof less.tree.Import) { @@ -276,15 +272,16 @@ function LessPlugin() { } } - return new Promise(function (resolve, reject) { - cacheInput = cacheInput.toString(); - if(!cacheInput) { - // TODO: explain the error - reject(new CssSyntaxError( - "No input is present" - )); - } - render(cacheInput, opts, function(err, tree, evaldRoot, imports) { + return new Promise(function (resolve, reject) { + + cacheInput = cacheInput.toString(); + if(!cacheInput) { + // TODO: explain the error + reject(new CssSyntaxError( + "No input is present" + )); + } + render(cacheInput, opts, function(err, tree, evaldRoot, imports) { if(err) { // Build PostCSS error return reject(new CssSyntaxError( @@ -302,11 +299,11 @@ function LessPlugin() { context = {}; // Convert Less AST to PostCSS AST convertImports(imports.contents); - + if(isFunction(opts.onImport)){ opts.onImport(Object.keys(postCssInputs)) } - + processRules(css, evaldRoot.rules); resolve(); } diff --git a/package.json b/package.json index cd31744..d7c7718 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "gulp-mocha": "^2.2.0", "gulp-postcss": "^6.1.1", "gulp-util": "^3.0.7", - "less": "^2.7.1", + "less": "^3.8.0", "less-plugin-future-compat": "^1.0.0", "postcss": "^5.0.10", "postcss-clean": "^1.0.2", From 16f4ba3aa9d5fa6cc121152a0954e6fd7a0edecd Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Mon, 7 Jan 2019 10:48:19 +0800 Subject: [PATCH 2/8] fix bug --- index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.js b/index.js index b04b011..6f543f8 100644 --- a/index.js +++ b/index.js @@ -300,10 +300,6 @@ function LessPlugin() { // Convert Less AST to PostCSS AST convertImports(imports.contents); - if(isFunction(opts.onImport)){ - opts.onImport(Object.keys(postCssInputs)) - } - processRules(css, evaldRoot.rules); resolve(); } From b5374db535d0e34f493bb8314ebffee59a91dd61 Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Tue, 8 Jan 2019 21:44:10 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=968=E4=BD=8D?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6f543f8..708fe53 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,11 @@ var postcss = require('postcss') var render = require("./lib/render")(less.ParseTree, less.transformTree); +var fround = function(value, numPrecision) { + value = Number(value); + return (numPrecision) ? Number((value + 2e-16).toFixed(numPrecision)) : value; +} + function LessPlugin() { var cacheInput; @@ -269,7 +274,11 @@ function LessPlugin() { container.append(process.directive(val)); } }); - } + } + // numPrecision = 8 + container.walkDecls(decl => { + decl.value = String(fround(decl.value, 8)); + }); } return new Promise(function (resolve, reject) { From a9c19079450dac5afa56878d7d310675b7d4b465 Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Wed, 9 Jan 2019 11:17:58 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=88=A0=E9=99=A4fixNumber=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/index.js b/index.js index 708fe53..2755368 100644 --- a/index.js +++ b/index.js @@ -6,11 +6,6 @@ var postcss = require('postcss') var render = require("./lib/render")(less.ParseTree, less.transformTree); -var fround = function(value, numPrecision) { - value = Number(value); - return (numPrecision) ? Number((value + 2e-16).toFixed(numPrecision)) : value; -} - function LessPlugin() { var cacheInput; @@ -275,10 +270,6 @@ function LessPlugin() { } }); } - // numPrecision = 8 - container.walkDecls(decl => { - decl.value = String(fround(decl.value, 8)); - }); } return new Promise(function (resolve, reject) { From 89aa24f6f8c5e45b4f9e07d317cb8922e0d9840e Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Wed, 9 Jan 2019 16:58:08 +0800 Subject: [PATCH 5/8] fix: add semicolon --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2755368..f33a3fb 100644 --- a/index.js +++ b/index.js @@ -191,7 +191,11 @@ function LessPlugin() { node.selectors = selectors; - var rule = postcss.rule(node); + var rule = postcss.rule(node); + + // add semicolon + rule.raws.semicolon = true; + processRules(rule, ruleset.rules); return rule; } @@ -219,7 +223,7 @@ function LessPlugin() { node.important = true; node.value = testImportant[1].trim(); } - } + } return postcss.decl(node); } From 3f543f3fd3b123adfee484fc85d10e376e4abda8 Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Mon, 14 Jan 2019 20:24:49 +0800 Subject: [PATCH 6/8] update for less@3.9.0 --- index.js | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f33a3fb..2b095ab 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,10 @@ var postcss = require('postcss') var render = require("./lib/render")(less.ParseTree, less.transformTree); +function isFunction(f){ + return typeof f === 'function'; +} + function LessPlugin() { var cacheInput; @@ -304,6 +308,10 @@ function LessPlugin() { // Convert Less AST to PostCSS AST convertImports(imports.contents); + if(isFunction(opts.onImport)){ + opts.onImport(Object.keys(postCssInputs)) + } + processRules(css, evaldRoot.rules); resolve(); } diff --git a/package.json b/package.json index d7c7718..a95db8e 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "gulp-mocha": "^2.2.0", "gulp-postcss": "^6.1.1", "gulp-util": "^3.0.7", - "less": "^3.8.0", + "less": "^3.9.0", "less-plugin-future-compat": "^1.0.0", "postcss": "^5.0.10", "postcss-clean": "^1.0.2", From ec73be84deb9f8bb48653a479f948eba37e89330 Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Tue, 15 Jan 2019 11:21:16 +0800 Subject: [PATCH 7/8] update package name --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a95db8e..d1672d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "postcss-less-engine", - "version": "0.6.2", + "name": "postcss-less-engine-latest", + "version": "1.0.0", "description": "PostCSS plugin for integrating the popular Less CSS pre-processor into your PostCSS workflow", "keywords": [ "postcss", From 4bf2851ceb0e99479d7292bbd9abbb8c4ed1e172 Mon Sep 17 00:00:00 2001 From: "yudong.shao" Date: Thu, 17 Jan 2019 13:49:22 +0800 Subject: [PATCH 8/8] version: 1.0.1 --- CHANGELOG.md | 4 ++++ package.json | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..af3663d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +## 1.0.0 +Support less@3 +## 1.0.1 +Move postcss & less to dependencies. \ No newline at end of file diff --git a/package.json b/package.json index d1672d7..a9a02f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-less-engine-latest", - "version": "1.0.0", + "version": "1.0.1", "description": "PostCSS plugin for integrating the popular Less CSS pre-processor into your PostCSS workflow", "keywords": [ "postcss", @@ -16,7 +16,10 @@ "url": "https://github.com/Crunch/postcss-less/issues" }, "homepage": "https://github.com/Crunch/postcss-less", - "dependencies": {}, + "dependencies": { + "postcss": "^5.0.10", + "less": "^3.9.0" + }, "devDependencies": { "autoprefixer": "^6.3.6", "ava": "^0.4.2", @@ -26,9 +29,7 @@ "gulp-mocha": "^2.2.0", "gulp-postcss": "^6.1.1", "gulp-util": "^3.0.7", - "less": "^3.9.0", "less-plugin-future-compat": "^1.0.0", - "postcss": "^5.0.10", "postcss-clean": "^1.0.2", "postcss-reporter": "^1.4.1" },