I've successfully setup my YUI Compressor JS. But it doesn't works like I would like it to.
I would like it to minify an entire directory every time a file in that directory gets changed.
So far I've made a scope with the directory, but the compressor only works on the file I have changed (in the scope), and not on the entire directory. So it only minify's that one file, and not the entire directory.
I've solved this by using gulp and setting it up accordingly. All I have to do then is running gulp and everything works.
Related
I am noticing that Aurelia is building to the scripts directory in my CLI project. Is it safe to add this directory to .gitignore, or is there some reason to track changes to 'scripts' in Git?
You can safely add scripts to the .gitignore file.
Aurelia CLI uses the scripts folder to store the generated scripts (vendor-bundle.js and app-bundle.js).
vendor-bundle.js is for libraries (e.g. aurelia-binding, bluebird and jquery).
app-bundle.js is for all your HTML, CSS and JS files from the src folder combined in one JS file.
Because these files are renewed every time you run au run or au bundle, there is no need for them to be in version control.
Depending on what functions the scripts have, you might want to leave them in the repo.
E.g.: you add a new member to your team, and said scripts might be required for your project to work. In which case, if they're not in the repo, he will bother one of you to transfer them to his computer.
Edit: If the scripts are automatically generated every time you build the project, or if they are downloaded via a packet-manager, then there is no need to leave them in the repository.
If this is the case, it's a safe bet you can add the folder to the .gitignore. If this is not the case, then it might be better to leave them in the repository.
This all depends on your project, where you are putting your scripts and how the frameworks work.
I have a MVC web application and I have deployed it.
After that I have modified a .js file which alone needs to be moved to production. I did moved the .js file and it doesn't take the latest changes js file in production, instead it use only the previous one during the deployment.
My question is
1. Is the .js files are also get complied along with the .dll files?
2. Is there a way to move the modified .js file alone to the production without moving the complied code?
That may be because of client browser caching. please check to remove caching.
So, just CTR + Shift + Delete and clear cached data.
Is the .js files are also get complied along with the .dll files
No, always calls file will complied.
Is there a way to move the modified .js
Simple way is to replace your latest js file with old js file
production without moving the complied code?
No, need to deploy whole code all the times.
Moreover, you can go though a document: Determining What Files Need to Be Deployed
And this: https://stackoverflow.com/a/9322505
I've been wasting a lot of time trying to learn how to deploy angular 2. I tried looking around how to do it on tomcat, because that's what I was ordered to do, but turns out tomcat isn't really used for this, is more java and jsp oriented, so I've read is better to use Apache HTTP server instead.
I just installed Apache server, and I just installed npm with gulp ( https://github.com/swirlycheetah/generator-angular2 ), and everything works fine: I can run my app on localhost:3030 with gulp but I now want to test it with Apache,
I've tried several things (since I haven't seen one single place explaining this, maybe it's a very basic thing to do?):
Configure apache .conf file to change the htdocs to a folder I've created. I've tested this works, I see the result on screen when I access localhost.
Compiled everything, got a folder called build with all my files changed to .js extention, so I figured, that must be it. I copied all the files in there, the lib folder created, and index.html and css files. Doesn't work.
Tried several combinations of picking some files that I figured would be necessary and not others. Doesn't work.
Copied the whole project that I've tested with gulp, with eclipse etc that works, including .ts and .d.ts files, which I've read shouldn't be there and are not necessary, and it works.
So I would like to know how is this really done, because I feel like I'm making no improvements. After reading post after post and blog after blog about I simply needed to transpile .ts files to .js, and simply put that javascript files on "some" folder the server uses, it would work. Not only it doesn't but when I use the original .ts files it does.
What might be going on and more important, how is this deployment (I guess it's called something else since I can't find much anything) properly done?
Make sure your .js file paths in your index.html page are correct. When you generate .js files in a folder(like build), your index.html may keep source paths for those .js files are like src="inline.js". So when you access index.html in build folder - localhost/build, it looks for those .js files in localhost only not localhost/build. Try to update source path of those .js files to /build/.
src="/build/inline.js".
you can do that using proxy option in Browser Sync..
proxy option link
I didn't try it but may be it will help you.
I need some help with organizing js files in VS.
So my problem is, that VS(MVC) put all js files by default into the script directory, but i also have js created by me, in a sub directory, like this:
Now my problem is that when i open the scripts folder, the js files installed by NuGet take 2-3 screens in length, so i either have to open/close it every time, or scroll trought like there is no tomorrow.
So my question is, is there any good solutions to it? Like moving all the files into a subdirectory, and change every bundles, and NuGet config, or should i create a separate script directory for my custom js files? Any good ideas?
You can place and use as many subdirectories you wish for your own scripts.
With the help of Bundle.IncludeDirectory all your scripts will be added to the bundle without having to define multiple bundles.
Concerning nuget I don't think you can (re)place those scripts at a location of your choice.
See Stackoverflow: Include all files in a folder in a single bundle
Sadly you cannot change the default folder that NuGet downloads the files. Is the author of the NuGet package that decides where it will get installed.
An alternative is to use Bower. With it you can control where files get downloaded (look at this question).
Or, as you said, move your own javascripts to another folder and forget about the default.
I'm starting a new project in Rails, and it looks like the application.js manifest file is doing something funny with the javascripts that I reference - does it cache those files as part of the asset pipeline?
Here's what happened. I added a javascript file named jquery.autoresize.js to the vendor/assets/javascripts folder, and then referenced the file in the application.js manifest like this:
//= require jquery.autoresize.js
Then I started up the rails server. But after navigating around in my app, I realized that I had accidentally added the wrong version of the jquery.autoresize.js file. So, I deleted that file and then added the correct version to the vendor/assets/javascripts folder. But, to my horror, when I reloaded the page, it is still loading the old javascript file.
I tried emptying my browser cache, then exiting and restarting the Rails server, but to no avail. I hacked a solution together by simply renaming my javascript file and referencing the new name, which worked fine. But there has got to be a better solution to this.
Does the new asset pipeline cache the files you reference somehow? If so, how can I clear that cache? Thanks for any help!
I'm assuming we're talking about the production environment.
When you change any of your javascripts or stylesheets in the production environment, you need to run rake assets:precompile; this task compiles and compresses the various .js and .css files and creates the application.js and application.css files that is loaded by your views.
It's possible that if you replaced jquery.autoresize.js with a version with an older timestamp, the precompile step might skip it, thinking the compiled version is up-to-date. You can avoid that by running rake assets:clean first, forcing it to rebuild everything in the public/assets directory from scratch.
Also try rake assets:clobber. This will totally reset everything and delete all compiled assets. In addition, I often need to set the environment before pushing to production by going: RAILS_ENV=production rake assets:precompile.
Rails automatically clears the cache for an individual file every time that the contents are edited. To clear the cache for a single file, simply open the file, edit a line of code, and re-save it. Rails will clear the cache for that file, and the browser will load the new file the next time the page is loaded.
The reason jquery.autoresize.js was using the old cached version of the file was because the old version was deleted and then the new version was copied and pasted with the same name into the same folder. Because the file itself was never edited, Rails continued to use the old file that was cached.
This is because the asset pipeline uses fingerprinting for the cache.
Fingerprinting is a technique that makes the name of a file dependent
on the contents of the file. When the file contents change, the
filename is also changed. For content that is static or infrequently
changed, this provides an easy way to tell whether two versions of a
file are identical, even across different servers or deployment dates.
When a filename is unique and based on its content, HTTP headers can
be set to encourage caches everywhere (whether at CDNs, at ISPs, in
networking equipment, or in web browsers) to keep their own copy of
the content. When the content is updated, the fingerprint will change.
This will cause the remote clients to request a new copy of the
content. This is generally known as cache busting.
The technique that Rails uses for fingerprinting is to insert a hash
of the content into the name, usually at the end. For example a CSS
file global.css could be renamed with an MD5 digest of its contents:
global-908e25f4bf641868d8683022a5b62f54.css
So, if you delete a file you're referencing in the manifest, and then copy in a new file with the same name, the cache busting never occurs. When you edit the file, the fingerprinting kicks in, and a new hash is generated for the file name. This busts the cache for that file.
For the full story, see What is Fingerprinting and Why Should I Care?.
rake tmp:clear did the trick for me, I'm using less-rails.
I use config.assets.version = '1.01019' in my application.rb to bust the entire cache. When I want to push a complete new version, I increment the version and that does the trick. This takes care of those edge cases where Rails does not recompile as asset for whatever reason.