generator-gulp-angular icon indicating copy to clipboard operation
generator-gulp-angular copied to clipboard

New script 'app' scripts file created after every `gulp build` command

Open jtallen opened this issue 10 years ago • 4 comments

I have edited my project's gulp files heavily from the generator's initial state, so I thought this was a problem with my changes at first, but I just downloaded an updated version of the vanilla generator and found the same issue.

This is my issue: After building my dist folder (using gulp build), changing my script (.js) files, and running a new gulp build. The old scripts files (in both dist/maps/scripts and dist/scripts) are not replaced with a new file, but the new file is simply added to the folder in addition to what is already there. This doesn't seem like it would be intended behavior to me... why would I want to clutter my production dist folder with old versions of my scripts?

If this is intended behavior, can someone please explain why? I can fix my problem by running gulp clean and then gulp build every time I want to make my new dist folder, but I don't understand what purpose there could be for having the build task operate this way. Additionally, which app-*.js file is selected? What if the old one is selected when in production? If I really am genuinely missing something here, I totally understand, but please explain what's going on to me, thanks!

jtallen avatar Jan 11 '16 22:01 jtallen

:+1:

drGrove avatar Jan 14 '16 01:01 drGrove

I think the main reason behind this is to prevent your app from stop responding to everyone immediately after a new deployment. Some files could be catched and they can try to get resources that don't exist anymore.

The corresponding (last) files are selected based on the ones injected into the dist/index.html during the build process.

Personally I've setup my build to always do a clean on every build for every environment but production. In production I always left the last two available unless we need to delete the previous one due to security reasons.

Hope this helps.

fvezzoso avatar Mar 23 '16 15:03 fvezzoso

Having the file generated with a hashcode in the filename is an important feature to have to resolve cache issues on releases. If accumulation of files is a problem, use gulp clean or even just "gulp" which already run the clean.

Swiip avatar Mar 28 '16 19:03 Swiip

It's true, running just "gulp" runs the default tasks, which runs clean and the build tasks. I think the docs are misleading here, as it makes it sound like the two tasks are equivalent -

"gulp or gulp build to build an optimized version of your application in /dist"

https://github.com/Swiip/generator-gulp-angular/blob/master/docs/usage.md

cm325 avatar Jun 16 '16 20:06 cm325