CSS Not Regenerated When LESS File Modified for Node.js on Windows - windows

I am using LESS with my node.js setup on my Windows dev machine. I've noticed that changes made to my .less file do not cause my .css file to be regenerated. If I want to see these changes, I am forced to delete the .css file. This will be regenerated the next time a request is made.
I was under the impression that the .css file was supposed to be regenerated after every change to the .less file (comparing the last modified date). I was curious if this was an issue specific to Windows.
Furthermore, I've noticed that the first request for a .css file forces it to be generated, but a 404 will be returned to the browser (aka no styles show up). Subsequent requests will find the .css file. I want to avoid ruining the first, unlucky user's experience.

Sounds to me like you are using express and/or connect middleware and you have your static handler before your compiler handler in the app configuration.
Switch them around.
The compiler will then get a chance to handle the request, seeing the file needs (re)compilation and once that is done the static handler kicks in and serves it.
app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));
app.use(express.static(__dirname + '/public'));

Related

Does Angular CLI prevent timestamp update for *.TS files?

After setting up an Angular 2 program using Angular CLI (following the procedure at https://angular.io/guide/quickstart) and using VS Code (https://code.visualstudio.com/) to work with the files I've noticed that the file timestamps for *.TS files do not get updated. Testing on Windows 10, the problem occurs even if I make a change to a TS file with Notepad and do so immediately after reboot. However, if I copy the TS files to another folder, they show updated timestamps.
When opening other folders, there is an instant display of files, but when opening the app folders with the TS files, there is a delay of several seconds, with a message "Working on it..."
The TS files had been associated with a video processing program ("transport stream" file), but I shifted the association to VS Code, but that didn't fix the problem.
I opened a bug report at https://github.com/Microsoft/vscode/issues/25569 but the VS Code folks could not reproduce the problem, suggesting that it is not seen for many VS Code users. That report is now is some sort of limbo in which it is listed as closed but one can still comment.
So I'm wondering whether the Angular CLI environment prevents timestamp update for the TS files.
Any suggestions on how to get the TS files in an Angular 2 project to show the current timestamp?
Addendum: the problem is not just for ts files. It extends to css files as well, as illustrated in this image in which the file system lists 19 April as the file date for styles.css, but the ToolTip for the file gives the more recent (correct) date:
Clearly some part of this environment is overruling one of 2 displays of the file date.
The problem is not the timestamp; it is the column displayed in Windows Explorer. Instead of the usual "Date Modified" column, "Date" was displayed. I don't think problem is caused by Angular CLI or VSCode. It looks like it is created by the video processing program ("transport stream") file type assignment; removing that file association and assigning *.ts to VSCode prevents the problem from occurring. However, this doesn't fix instances in which it occurred already; here is how to fix those:
In Windows Explorer click View on the menu, then "Add Columns". Uncheck "Date" and check "Date Modified". You may want to remove "Length" as well.

Typescript 1.0 map files do not load

In VS2013 update 2 RC (Typescript 1.0 RTM) I cannot debug TypeScript files in one of my projects. I have traced this back to the map file declaration. By default my JS file contains:
//# sourceMappingURL=general.js.map
Which should be correct, the map file is in the same folder as the TS and JS files. However it doesn't work. if I manually edit the file, specifying the full path, it works:
//# sourceMappingURL=C:/Users/myname/Documents/Visual Studio 2013/Projects/Test/JSLib/general.js.map
This confuses me, because surely the browser shouldn't understand the full path, eg outside the IISExpress web site?
Can anyone suggest a way to get map files working with the first mapping? Thanks
Windows 8.1 x64, IE11
Update: the app, running through IISExpress, uses Windows authentication. if I turn this off the map files load! Also, checking the output window I see:
SourceMap http://localhost:53524/JSLib/general.js.map read failed: The remote server returned an error: (401) Unauthorized.'iexplore.exe' (Script): Loaded 'http://localhost:53524/JSLib/'.
My IIS Express logs contain
2014-04-12 13:58:24 ::1 GET /JSLib/general.js.map - 53524 - ::1 - - 401 2 5 0
But I can browse to http://localhost:53524/JSLib/general.js.map fine in IE. So what's making the call for the map file (VS?) and how to I get it to use my credentials?
I too have been experiencing this problem. I am sorry to say that I do not know what the root of the problem is. However, I have found a workaround.
Open your project properties and go to the 'TypeScript Build' tab. In the 'Debugging' section, check the 'Specify root directory of the source maps' option and enter the value $(ProjectDir)\Scripts.
This works with Windows Authentication enabled and with the default 'sourceMappingUrl'.

"open in IE 1.4" addon stopped working

Whenever I press on the open in IE icon, I get an error in the console:
Error: NS_ERROR_FILE_NOT_FOUND: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIProcess.init]
Source File: chrome://openinie/content/openinie.js
Line: 126 (This happened ever since upgrade to 16.0 and I assume it's probably security related)
I found that js file to be inside some "openinie#wittersworld.com.xpi" file (which I cleverly renamed to zip), and saw the offending line:
var iePath = openinie.getIEPath();
// create an nsILocalFile for the executable
var file = Components.classes["#mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(iePath);
// create an nsIProcess
var process = Components.classes["#mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(file); // <-line 126
is it possible to fix it and "re-compile" it zipping and renaming?
(I assume it's something with security maybe).
can I debug this using for example an alert box to display values of variables?
is it possible to fix it and "re-compile" it zipping and renaming
Yes, you can simply replace a file in the ZIP archive, most extensions aren't signed (you can remove the META-INF directory from the XPI file if this one is). In fact, for your debugging it is better to unpack openinie#wittersworld.com.xpi into a directory named openinie#wittersworld.com in the same folder and remove the original file - this way you won't need to pack/unpack on each change. You should also start Firefox with the -purgecaches command line parameter, otherwise the file you are changing might get cached.
can I debug this using for example an alert box to display values of variables?
Yes. However, I would rather recommend Components.utils.reportError() method that will log to the Error Console (press Ctrl-Shift-J to open it) without opening modal dialogs. In this particular case I would write:
Components.utils.reportError(iePath);
This seems to point to a non-existent file meaning that the getIEPath() function is faulty.
Good luck!

Build error "The process cannot access the file because it is being used by another process" in WP7?

I guess we can add this question to the list. Basically It's been taking me twice the time to try something out because everytime I try to debug my app I have to wait about a minute to lauch the app. There are 3 files in order that it complains about.
Resources file (.g)
Program Debug Database
DLL (.dll)
I tried removing the first two, but then it complains about the DLL file. Strangely enough I have never encountered this and I've been using the the WP7 emulator in VS2010 for about a year. Any ideas? Is there possibly a setting or cache that can be deactivated?
Basically when you add images to your project, by default they are added as a resource. By doing this everytime you try to build the project the images are saved in the dll file thus the long wait time. I set 95% of my images to content and have not had the issue since.

VS2008 Website Application Project, Long Wait to see page after build

Just started a new Web Site Application project, and just find it takes to long to open my webpage straight I build it. This is a brand new project which has just the minimum number of files, but there is other files in the folder which are not part of the project which are not included in my project.
Anyway I press build, build complete, try open the webpage i.e. http://unitedcms/default.aspx.
Need to wait like 1 min before it loads, after that initial load it loads instantly ofcourse im just wondering why that initial load takes so long ?
The reason for this is that IIS/Cassini compiles your project after every build. This compilation takes time to complete. Once compiled, IIS/Cassini stores them in cache. On subsequent requests, IIS/Cassini will not recompile the code but serve it from the cache.
That's the reason your first request is always slow.
Here is an example. Using notepad, edit your web.config file (just add an empty line or space). Save it. And then try to open your site again. It will take time to load. That's because IIS checks your web.config file's last modified time stamp and if it's newer than the one in cache, it will re-compile the code.
Hope this helps.

Resources