Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

gulp not cleared .tmp after a file change #87

Closed
gabrieldevelops opened this issue Jul 14, 2016 · 33 comments
Closed

gulp not cleared .tmp after a file change #87

gabrieldevelops opened this issue Jul 14, 2016 · 33 comments

Comments

@gabrieldevelops
Copy link

I realized that while the gulp is running in server mode, it does not perform cleaning the .tmp and the server is running on top of that folder files.

I resolved this issue add 'clean' in task serve, in gulp file:
gulp.task('serve', gulp.series('clean','inject', 'watch', 'browsersync'));

any better suggestions?

@micaelmbagira
Copy link
Member

Hi @gabrieldevelops why do you need to clean the .tmp folder ?

@gabrieldevelops
Copy link
Author

@micaelmbagira gulp serve use the .tmp files in browser, at least for me

@micaelmbagira
Copy link
Member

Alright, about this one, we have a fresh PR to fix the conflict that can occur when serving .tmp and src FountainJS/generator-fountain-browsersync#21

@micaelmbagira
Copy link
Member

@gabrieldevelops Does it answer to your question ?

@gabrieldevelops
Copy link
Author

@micaelmbagira Yes, answer my question

@gabrieldevelops
Copy link
Author

I just need to update the generator?

@micaelmbagira
Copy link
Member

Nope, it's not published yet but what you have to do is reverse the order or server.baseDir in conf/browsersync.conf.js:

baseDir: [
  conf.paths.tmp,
  conf.paths.src
]

@gabrieldevelops
Copy link
Author

@micaelmbagira this is conf result in blank page, in Sources(F12 browser), not show app/src folder

@micaelmbagira
Copy link
Member

@gabrieldevelops I don't understand...

@gabrieldevelops
Copy link
Author

gulp

@micaelmbagira
Copy link
Member

Can you send a github project so that I take a look ?

@gabrieldevelops
Copy link
Author

@micaelmbagira
Copy link
Member

@gabrieldevelops I tried to replace <div ui-view></div> with <div>hello</div> in index.html and it works so the problem is more about your code.

@gabrieldevelops
Copy link
Author

@micaelmbagira after configure

baseDir: [
conf.paths.src,
conf.paths.tmp
]

the task inject not working, not inject files in index

@micaelmbagira
Copy link
Member

I don't know. I tested your project with baseDir: [conf.paths.src, conf.paths.tmp] and it works.

@dman777
Copy link

dman777 commented Aug 31, 2016

UPDATE: The reverse order of conf.paths.src and conf.paths.tmp is not a fix. It creates a new breakage. In the order above, bower files do not get injected into the index.html. This definatelly should re-opened.

I just instealled the latest stable fountain release tonight(Aug 31 yo fountain-webap) for angular and I hit this bug/issue also. I reversed the order which fixed this issue.

Maybe this issue should stay open untill the PR is merged and available in the latest release?
I got lucky in finding this issue easiley, but it could make someone pull thier hair out if they are making removing files and not realizing they are still being injected.

Also, maybe it would be a good idea to clear out the .tmp directory for every gulp server start? Tech. it shouldn't be needed, but maybe for good practice for anomalies like this.

module.exports = function () {
  return {
    port: 9000,
    server: {
      baseDir: [
        conf.paths.src,
        conf.paths.tmp
      ],
      routes: {
        '/bower_components': 'bower_components'
      }
    },
    open: false
  };
};

@LuukMoret
Copy link

I also had this issue and had to resolve this by changing the task
gulp.task('serve', gulp.series('inject', 'watch', 'browsersync')); to
gulp.task('serve', gulp.series('clean', 'inject', 'watch', 'browsersync'));

@dman777
Copy link

dman777 commented Aug 31, 2016

👍 Thanks, this did the trick.

This is still major breakage because reversing order causes bower files not to be injected.

@micaelmbagira
Copy link
Member

micaelmbagira commented Aug 31, 2016

@dman777 As you can see in this commit, the order of src and .tmp has been reversed only for SystemJS FountainJS/generator-fountain-browsersync@de62a7e.
When you generate a project with another option than SystemJS, for instance Bower or Webpack you have

server: {
      baseDir: [
        conf.paths.tmp,
        conf.paths.src
      ],

So the issue is different.

@dman777
Copy link

dman777 commented Aug 31, 2016

@micaelmbagira Ok, thanks. I mis-understood. I thought the reverse fix was for non SystemJs since the issue also existed for non SystemJs.

@micaelmbagira
Copy link
Member

If it still makes sense, you can open an issue regarding yours

@dman777
Copy link

dman777 commented Aug 31, 2016

Could we re-open this one for convience? Since the title states the issue and all notes are on here? Simple fix, unless you wanted to code to handle/detect removing files dynamically.

@micaelmbagira
Copy link
Member

Ok, can you explain the exact bug you had then ?

@micaelmbagira micaelmbagira reopened this Aug 31, 2016
@dman777
Copy link

dman777 commented Aug 31, 2016

Sure....

when running gulp serve if I remove a file(s) in src/app/ it will reside in the .tmp/ and be injected into the app. Regardless of restarting gulp serve.

This will not be apparent to the developer. He/She will have side effects such as code changes on existing .js sheets that will not take effect(being that the old .js files are still being injected and still taking effect).

Restarting gulp with cleaning the /.tmp is a good fix. Although it will require restarting gulp if a file is removed. This has bitten me a few times in developing.

Coding to detect a file removed real time and remove it in ./tmp would be nice, but might be unwanted because of the extra code overhead and side effects that go with that.

@matheusdavidson
Copy link

matheusdavidson commented Sep 26, 2016

I'm also having the same problem.

Usually when i create a new component/module/directive, i copy and paste an existing component/module/directive folder so i don't have to write everything again, just change names and code i need.

Angular started complaining about component name colision and i couldn't understand why. After some debugging, i found that files remained as i copied in .tmp folder, they didn't change as i was editing.

To solve the problem, i have to manually delete the .tmp folder and restart the server.

@jensenkd
Copy link

I'm having the same problem. .tmp not getting updated.

@zmts
Copy link

zmts commented Sep 30, 2016

Same problem. I fix it by adding 'clean' task in 'inject' task
gulp.task('inject', gulp.series('clean', gulp.parallel('styles', 'scripts'), 'inject'));
After any changes in js files .tmp folder is cleaning

@ozluy
Copy link

ozluy commented Nov 24, 2016

+1 same issue!!! caching and does not recognize changes

@matheusdavidson
Copy link

Guys, be careful with the solution above(@zmts, @LuukMoret, @gabrieldevelops), when you add clean task in the inject task you'll have problems when running npm run serve:dist or npm run build:
Error: File not found with singular glob: \www\myproject\.tmp\templateCacheHtml.js

It happens because templateCache.js is generated in the partials task which is done before inject, at this point clean will wipe out .tmp folder resulting in the error mentioned above.

If you run npm run serve it will be ok because no templateCache is generated.

@zmts
Copy link

zmts commented Dec 4, 2016

@matheusdavidson Before make build just remove clean task from inject and all be fine.

@matheusdavidson
Copy link

did that @zmts, just wanted to document this here so people can find it if they get the same error.

@matheusdavidson
Copy link

Is this fixed already? Updated and i still need to apply the fix.

@micaelmbagira
Copy link
Member

Won't fix. But you can add the clean task wherever you need in your gulp process @matheusdavidson

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants