Skip to content

Commit 38a8664

Browse files
committed
Merge branch 'less.js/1.5.0-wip'
Conflicts: .jshintrc Makefile package.json
1 parent aa7e3cc commit 38a8664

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1280
-674
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ npm-debug.log
1414
tmp
1515
test/browser/less.js
1616
test/browser/test-runner-*.htm
17+
test/sourcemaps/*.map
18+
test/sourcemaps/*.css

.jshintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
benchmark/
2+
build/
3+
dist/
4+
node_modules/
5+
test/browser/

.jshintrc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
{
2-
"curly": true,
3-
"eqeqeq": true,
4-
"evil": true,
5-
"immed": true,
6-
"latedef": true,
7-
"newcap": true,
8-
"noarg": true,
9-
"sub": true,
10-
"undef": true,
11-
"unused": true,
12-
"boss": true,
13-
"eqnull": true,
14-
"node": true
2+
"evil": true,
3+
"boss": true,
4+
"expr": true,
5+
"laxbreak": true,
6+
"node": true,
7+
"unused": "vars",
8+
"noarg": true
159
}

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 1.5.0 WIP
22

3-
- support for import inline option to include css that you do not want less to parse e.g. `@import (inline) "file.css";`
3+
- support for import inline option to include css that you do NOT want less to parse e.g. `@import (inline) "file.css";`
44
- better support for modifyVars (refresh styles with new variables, using a file cache), is now more resiliant
55
- support for import reference option to reference external css, but not output it. Any mixin calls or extend's will be output.
66
- support for guards on selectors (currently only if you have a single selector)
@@ -12,6 +12,7 @@
1212
- Fix the saturate function to pass through when using the CSS syntax
1313
- Added svg-gradient function
1414
- Added no-js option to lessc (in browser, use javascriptEnabled: false) which disallows JavaScript in less files
15+
- switched from the little supported and buggy cssmin (previously ycssmin) to clean-css
1516

1617
# 1.4.2
1718

Makefile

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#
2+
# Run all tests
3+
#
4+
test:
5+
node test/less-test.js
6+
7+
#
8+
# Run benchmark
9+
#
10+
benchmark:
11+
node benchmark/less-benchmark.js
12+
13+
#
14+
# Build less.js
15+
#
16+
SRC = lib/less
17+
HEADER = build/header.js
18+
VERSION = `cat package.json | grep version \
19+
| grep -o '[0-9]\.[0-9]\.[0-9]\+'`
20+
DIST = dist/less-${VERSION}.js
21+
RHINO = dist/less-rhino-${VERSION}.js
22+
DIST_MIN = dist/less-${VERSION}.min.js
23+
24+
browser-prepare: DIST := test/browser/less.js
25+
26+
alpha: DIST := dist/less-${VERSION}-alpha.js
27+
alpha: DIST_MIN := dist/less-${VERSION}-alpha.min.js
28+
29+
beta: DIST := dist/less-${VERSION}-beta.js
30+
beta: DIST_MIN := dist/less-${VERSION}-beta.min.js
31+
32+
less:
33+
@@mkdir -p dist
34+
@@touch ${DIST}
35+
@@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST}
36+
@@echo "(function (window, undefined) {" >> ${DIST}
37+
@@cat build/require.js\
38+
build/browser-header.js\
39+
${SRC}/parser.js\
40+
${SRC}/functions.js\
41+
${SRC}/colors.js\
42+
${SRC}/tree/*.js\
43+
${SRC}/tree.js\
44+
${SRC}/env.js\
45+
${SRC}/visitor.js\
46+
${SRC}/import-visitor.js\
47+
${SRC}/join-selector-visitor.js\
48+
${SRC}/to-css-visitor.js\
49+
${SRC}/extend-visitor.js\
50+
${SRC}/browser.js\
51+
build/amd.js >> ${DIST}
52+
@@echo "})(window);" >> ${DIST}
53+
@@echo ${DIST} built.
54+
55+
browser-prepare: less
56+
node test/browser-test-prepare.js
57+
58+
browser-test: browser-prepare
59+
phantomjs test/browser/phantom-runner.js
60+
61+
browser-test-server: browser-prepare
62+
phantomjs test/browser/phantom-runner.js --no-tests
63+
64+
jshint:
65+
node_modules/.bin/jshint --config ./.jshintrc .
66+
67+
test-sourcemaps:
68+
node bin/lessc --source-map --source-map-inline test/less/import.less test/sourcemaps/import.css
69+
node bin/lessc --source-map --source-map-inline test/less/sourcemaps/basic.less test/sourcemaps/basic.css
70+
node node_modules/http-server/bin/http-server test/sourcemaps -p 8083
71+
72+
rhino:
73+
@@mkdir -p dist
74+
@@touch ${RHINO}
75+
@@cat build/require-rhino.js\
76+
build/rhino-header.js\
77+
${SRC}/parser.js\
78+
${SRC}/env.js\
79+
${SRC}/visitor.js\
80+
${SRC}/import-visitor.js\
81+
${SRC}/join-selector-visitor.js\
82+
${SRC}/to-css-visitor.js\
83+
${SRC}/extend-visitor.js\
84+
${SRC}/functions.js\
85+
${SRC}/colors.js\
86+
${SRC}/tree/*.js\
87+
${SRC}/tree.js\
88+
${SRC}/rhino.js > ${RHINO}
89+
@@echo ${RHINO} built.
90+
91+
min: less
92+
@@echo minifying...
93+
@@uglifyjs ${DIST} > ${DIST_MIN}
94+
@@echo ${DIST_MIN} built.
95+
96+
alpha: min
97+
98+
beta: min
99+
100+
alpha-release: alpha
101+
git add dist/*.js
102+
git commit -m "Update alpha ${VERSION}"
103+
104+
dist: min rhino
105+
git add dist/*
106+
git commit -a -m "(dist) build ${VERSION}"
107+
git archive master --prefix=less/ -o less-${VERSION}.tar.gz
108+
npm publish less-${VERSION}.tar.gz
109+
110+
stable:
111+
npm tag less@${VERSION} stable
112+
113+
114+
.PHONY: test benchmark

bin/lessc

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var args = process.argv.slice(1);
1111
var options = {
1212
depends: false,
1313
compress: false,
14-
yuicompress: false,
14+
cleancss: false,
1515
max_line_len: -1,
1616
optimization: 1,
1717
silent: false,
@@ -52,6 +52,8 @@ var checkBooleanArg = function(arg) {
5252
return Boolean(onOff[2]);
5353
};
5454

55+
var warningMessages = "";
56+
5557
args = args.filter(function (arg) {
5658
var match;
5759

@@ -95,7 +97,11 @@ args = args.filter(function (arg) {
9597
options.depends = true;
9698
break;
9799
case 'yui-compress':
98-
options.yuicompress = true;
100+
warningMessages += "yui-compress option has been removed. assuming clean-css.";
101+
options.cleancss = true;
102+
break;
103+
case 'clean-css':
104+
options.cleancss = true;
99105
break;
100106
case 'max-line-len':
101107
if (checkArgFunc(arg, match[2])) {
@@ -132,6 +138,21 @@ args = args.filter(function (arg) {
132138
options.dumpLineNumbers = match[2];
133139
}
134140
break;
141+
case 'source-map':
142+
if (!match[2]) {
143+
options.sourceMap = true;
144+
} else {
145+
options.sourceMap = match[2];
146+
}
147+
break;
148+
case 'source-map-rootpath':
149+
if (checkArgFunc(arg, match[2])) {
150+
options.sourceMapRootpath = match[2];
151+
}
152+
break;
153+
case 'source-map-inline':
154+
options.outputSourceFiles = true;
155+
break;
135156
case 'rp':
136157
case 'rootpath':
137158
if (checkArgFunc(arg, match[2])) {
@@ -169,7 +190,22 @@ if (input && input != '-') {
169190
var output = args[2];
170191
var outputbase = args[2];
171192
if (output) {
193+
options.sourceMapOutputFilename = output;
172194
output = path.resolve(process.cwd(), output);
195+
if (warningMessages) {
196+
sys.puts(warningMessages);
197+
}
198+
}
199+
200+
options.sourceMapBasepath = process.cwd();
201+
202+
if (options.sourceMap === true) {
203+
if (!output) {
204+
sys.puts("the sourcemap option only has an optional filename if the css filename is given");
205+
return;
206+
}
207+
options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";
208+
options.sourceMap = path.basename(options.sourceMapFullFilename);
173209
}
174210

175211
if (! input) {
@@ -202,6 +238,12 @@ if (options.depends) {
202238
sys.print(outputbase + ": ");
203239
}
204240

241+
var writeSourceMap = function(output) {
242+
var filename = options.sourceMapFullFilename || options.sourceMap;
243+
ensureDirectory(filename);
244+
fs.writeFileSync(filename, output, 'utf8');
245+
};
246+
205247
var parseLessFile = function (e, data) {
206248
if (e) {
207249
sys.puts("lessc: " + e.message);
@@ -230,7 +272,14 @@ var parseLessFile = function (e, data) {
230272
verbose: options.verbose,
231273
ieCompat: options.ieCompat,
232274
compress: options.compress,
233-
yuicompress: options.yuicompress,
275+
cleancss: options.cleancss,
276+
sourceMap: Boolean(options.sourceMap),
277+
sourceMapFilename: options.sourceMap,
278+
sourceMapOutputFilename: options.sourceMapOutputFilename,
279+
sourceMapBasepath: options.sourceMapBasepath,
280+
sourceMapRootpath: options.sourceMapRootpath || "",
281+
outputSourceFiles: options.outputSourceFiles,
282+
writeSourceMap: writeSourceMap,
234283
maxLineLen: options.maxLineLen,
235284
strictMath: options.strictMath,
236285
strictUnits: options.strictUnits

build/browser-header.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if (typeof(window.less) === 'undefined') { window.less = {}; }
2+
less = window.less;
3+
tree = window.less.tree = {};
4+
less.mode = 'browser';

build/rhino-header.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if (typeof(window) === 'undefined') { less = {} }
2+
else { less = window.less = {} }
3+
tree = less.tree = {};
4+
less.mode = 'rhino';

0 commit comments

Comments
 (0)