Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep track of what files are imported (and watches them with lessc --watch) #246

Closed
wants to merge 10 commits into from

Conversation

@wvl
Copy link

commented Apr 25, 2011

As part of the server side integration, I wanted to know the dependency information for each less file. This patch accomplishes that:

af81c63 -- keeps track of the imported files, with tests.
29a1fed -- adds the dependencies to the list of watched files (for the --watch option).

Since I built this functionality on top of my no_exit branch and changes, the pull request includes those commits by default. The above two commits are the changes for this functionality.

Thanks

poswald and others added 10 commits Feb 8, 2011
Process less file on startup, log output
With patch adding watch command, it didn't 
process the file until a new change was made.

When the file is written, it is not obvious that
something actually happened, so make that 
explicit.
Avoid modifying `require.paths`:
http://nodejs.org/docs/v0.4.4/api/modules.html -

**Note:** Please Avoid Modifying `require.paths`
For compatibility reasons, require.paths is still 
given first priority in the module lookup process.
However, it may disappear in a future release.

While it seemed like a good idea at the time, and
enabled a lot of useful experimentation, in
practice a mutable require.paths list is often a
troublesome source of confusion and headaches.
Handle errors without exiting. + Test errors...
With process.exit called on errors, it is 
impossible to put less inside any other process.

This commit aims to remove the process.exit calls
and handle any errors with callbacks. It also
adds the asynchronous errors caused by import
to the call chain, so any file import error will
be properly returned.

With errors not calling process.exit, we can add
some tests for some error conditions.
Add browser tests. Note that three are failing:
comments
mixin-args
variables

All fail to render in the browser.
Merge branch 'browser_tests'
* browser_tests:
  Add browser tests. Note that three are failing:
@wvl

This comment has been minimized.

Copy link
Owner Author

commented on test/less-test.html in 96a43e3 Apr 25, 2011

I was going to use the existing css files, and just rewrite the url's with the expected values in the browser. However, that got a little complicated, so I just made a separate browser version of these files.

@andriijas

This comment has been minimized.

Copy link

commented May 10, 2011

Im also missing the watch command in lessc nowadays. Please consider merge.

@EmilStenstrom

This comment has been minimized.

Copy link

commented May 13, 2011

I'm running the @wvl branch and it works great. A MUST for people that want to precompile stuff on windows.

@wvl

This comment has been minimized.

Copy link
Author

commented Jul 10, 2011

Alexis, are you open to merging these changes? I would like to publish my code that uses less, however it needs these changes.

If there's any issue with the code, or the format of the patches, or whatever, please let me know.

Thanks,
Wayne

@cloudhead

This comment has been minimized.

Copy link
Member

commented Aug 22, 2011

I'm against having a watch mode in the command line, as there is already a (better) watch-mode on the browser side... but now I realize I haven't documented that.

@wvl

This comment has been minimized.

Copy link
Author

commented Aug 22, 2011

Does the browser side watch also track dependencies? That is the main reason for this pull request -- af81c63 keeps track of the dependencies.

A command line watch mode can be done externally (I do it this way right now), but keeping track of the dependencies is required, imo.

@sroussey

This comment has been minimized.

Copy link

commented Sep 2, 2011

Watch on a server is important when you are not editing local files. Please consider for those of us with a workflow that doesn't match yours. Thanks!

@mpdeimos

This comment has been minimized.

Copy link

commented Sep 10, 2011

I'd also like to have this feature in the cmd client since we will not serve the less files to the client.

@EmilStenstrom

This comment has been minimized.

Copy link

commented Sep 10, 2011

I'm not serving less files to the client either, we don't want JS dependence for layout. You could argue that the browser solution is only for development, but using a different technique for development and production is a recipe for disaster. So, I would very much like to use the server side command line version with a --watch command.

I'm also aware that this pull request fixes two different issues, only one which I have an opinion on.

@krunkosaurus

This comment has been minimized.

Copy link

commented Dec 22, 2011

Command like watch feature is critical for many people's workflows. I was about to switch from Sass to Less so that I can keep all dev tools in Node but this is a deal breaker. Who uses Less on the browser side anyways? My client side JS is busy doing other stuff.

@cloudhead

This comment has been minimized.

Copy link
Member

commented Dec 22, 2011

You develop with it on the browser, it's much faster. On the server, there are already plenty of tools which can watch files and run commands on change.

@cloudhead cloudhead closed this Dec 22, 2011

@krunkosaurus

This comment has been minimized.

Copy link

commented Dec 24, 2011

The Less website didn't really discuss the concept of using the browser version of Less only for web dev only which I can agree with and don't mind doing but after investigation this leads to the error "Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101" in Chrome browsers on localhost.

I know there's a couple of ways to work around this issue (including using Safari or Firefox or open Chrome with "google-chrome -allow-file-access-from-files" flag, or set up /etc/host entry and run local web server) but I'm not interested in changing anything (including my browser) when Sass is working fine. Will wait to see what the future holds. Thanks for the response, though.

@cloudhead

This comment has been minimized.

Copy link
Member

commented Dec 24, 2011

Yea, that is my fault (lack of documentation). Chrome has some restrictions with the file:// protocol indeed, I usually run a web-server, which negates the issue, you can also do that with:

    $ python -m SimpleHTTPServer

It will run a static file server in the current directory.

There are of course other solutions to watch files as I mentioned, such as watchr or watch.

Cheers

@EmilStenstrom

This comment has been minimized.

Copy link

commented Dec 25, 2011

I respect your decision not to implement --watch.

Your workaround won't work for me because it makes dev and prod be too different. This means that you won't be able to test your production stack properly. If your dev env. uses another version of less to compile the script, you won't notice that until you deploy to production. I like to keep dev and prod in sync. --watch would help me do that.

I'll look elsewhere for a CSS precompilation tool.

@andriijas

This comment has been minimized.

Copy link

commented Dec 25, 2011

@EmilStenstrom

This comment has been minimized.

Copy link

commented Dec 25, 2011

@andriijas: Less.app is great, but Mac only. I use a Win computer at home, and have often worked in team where not everyone uses a Mac.

@andriijas

This comment has been minimized.

Copy link

commented Dec 25, 2011

@EmilStenstrom I know. I have the same problem with my linux colleagues which is the exact reason I want --watch to get back in.

Honestly, I dont think it's much we are asking for. I mean, does it add bloat? no.

@cloudhead

This comment has been minimized.

Copy link
Member

commented Dec 26, 2011

There is also http://crunchapp.net/ and http://wearekiss.com/simpless which both work on linux/windows.

And as I mentioned, several command-line tools:
https://github.com/mynyml/watchr
http://linux.about.com/library/cmd/blcmdl1_watch.htm
https://github.com/visionmedia/watch

@andriijas: A file watcher simply doesn't belong in a compiler, I'd be recreating something poorly, which already exists.

@EmilStenstrom

This comment has been minimized.

Copy link

commented Dec 27, 2011

@cloudhead: I see how you are thinking. This project is just the compiler, a library that other tools should include and build user-facing stuff on top off. I'll use one of the tools you suggest.

@cloudhead

This comment has been minimized.

Copy link
Member

commented Dec 27, 2011

Yes, I also have to think as a maintainer.. the more features I add, the more I have to maintain in the long run, the more bugs etc..

@wvl

This comment has been minimized.

Copy link
Author

commented Dec 27, 2011

Ok, so less.js is a library that other tools should build on top of. I can get behind that, it is how I started using less in the first place. However, how many libraries have calls to process.exit? Are you planning on merging the no_exit pull request (#244)?

wvl@deb5b3e

@cloudhead

This comment has been minimized.

Copy link
Member

commented Dec 27, 2011

The calls to exit() are inside the standalone bin/lessc script, not the library part..

@andriijas

This comment has been minimized.

Copy link

commented Dec 27, 2011

Lets leave it at that, I think this discussion has been sorted out.

@jeeyoungk

This comment has been minimized.

Copy link

commented Apr 23, 2012

Not implementing --watch feature is pretty bad for me. I have quite a number of .less files being referenced in my project, and refreshing the page takes 600ms just to re-compile the less files, even if i'm not actively changing the less files. --watch mode will solve the both problems - I won't have to actively recompile less files even if I make changes, and my development cycle becomes way faster because i don't have to wait 600 ms for the less files to recompile.

@Evanlec

This comment has been minimized.

Copy link

commented Apr 25, 2012

@jeeyoungk
Unfortunately you will have to setup something with inotify / make in order to recompile your less files when they change.
I was for adding the --watch feature, but we have been overruled.

@romaninsh

This comment has been minimized.

Copy link

commented Nov 28, 2012

Here is the solution how to watch files with "inotify" and compile them with LESS.

http://webmasters.stackexchange.com/questions/38386/how-to-automatically-compile-less-into-css-on-the-server/38387#38387

stefanklug pushed a commit to stefanklug/carto that referenced this pull request Feb 25, 2013
@jgonera

This comment has been minimized.

Copy link

commented Feb 28, 2013

If anyone's interested, I wrote another .less file watcher (no GUI, just command line) that tracks imported files because what I found didn't work for my particular case. It's here: https://github.com/jgonera/autoless

@lukeapage

This comment has been minimized.

Copy link
Member

commented Feb 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.