doronsever / generator-gulp-angular-subtask

A helper generator for generator-gulp-angular to create sub tasks
49 stars 19 forks source link

questions about inject:js behaviour #4

Closed poliveira89 closed 9 years ago

poliveira89 commented 9 years ago

Hello,

Disclaimer: I know that gulp <command> and gulpfile.js from a generated project is not "generator-gulp-angular-subtask" fault.

I'm using this project, but I have been struggling with something. With the Javascript files (more specifically with Angular files: controllers, providers, services, etc).

So everytime I create a file with this generator, it will append manually before the <!-- inject:partials --> on the index.html without gulp wiredep or gulp inject:js, like this:

    <!-- build:js scripts/vendor.js -->
    <!-- bower:js -->
    <script src="../bower_components/jquery/dist/jquery.js"></script>
    <script src="../bower_components/angular/angular.js"></script>
    ...
    <!-- endbower -->
    <!-- endbuild -->

    <!-- build:js({.tmp,src}) scripts/app.js -->
    <!-- inject:js -->
    ...
    <!-- endinject -->

    <script src="app/example/controllers/example-controller.js"></script>
    <!-- inject:partials -->
    <!-- angular templates will be automatically converted in js and inserted here -->
    <!-- endinject -->
    <!-- endbuild -->

And every time I delete manually the folders containg this controllers (etc), the gulp wiredep fixes the content for <!-- inject:js --> but not remove those before <!-- inject:partials -->.

This behaviour seems strange for me, what do you think? It's expected or premeditated? This may not be the core of my problem, but I think it's related, which is:

  1. index.html content fully erased
  2. dependecy injection or management (how you prefer to call it) affected: not enabling to "load" or "use " the angular components

I hope this issue, starts some kind of conversation which will help me understand this project and related operations and if those causes me trouble... thank you :smile:

doronsever commented 9 years ago

Hi, Which generator-gulp-angular version are you using? In version 0.81 they changed how index.html is working https://github.com/Swiip/generator-gulp-angular/pull/217 This might have cause some problems with my project. I still didn't upgrade to 0.81 (will do it in the next few weeks) then i could see if there is a problem with injecting the js files (I think that it is not needed anymore since they have coffee script and js watchers in the directories)

poliveira89 commented 9 years ago

First of all, thank you for you quick reply. :+1:

This are my generators versions:

doronsever commented 9 years ago

As i thought... When i started this project, there was no coffeescript support in generator-gulp-angular so i had to inject the generated file manually. Now that generator-gulp-angular does support coffeescipt (and other languages), the whole manual injection part is no longer needed and can rely entirely on wiredep.

I will try to do the modification as soon as possible.

Thank you so much for your help!

poliveira89 commented 9 years ago

Thank you for your replies :smiley:

I understand that you did this "manual operation" to overcome a flaw on generator-gulp-angular, but until you update this project (no pressure on that, seriously :+1: ), how can I fix this on my side?

Remove every <script> added between <!-- inject:js --> and <!-- inject:partials -->?

doronsever commented 9 years ago

From what i understand, your problem is when you delete a subtask file and directory, so you end up with a script tag without an actual file, right? If that the case, you need to delete the script tag file from index.html manually. This is the behaviour from day one of this project... I need to rely on wiredep the include and the files each time index.html file is generated.

poliveira89 commented 9 years ago

Ok, thanks :+1:

doronsever commented 9 years ago

I've created a new branch - https://github.com/doronsever/generator-gulp-angular-subtask/tree/updating-angular-gulp which suppose to fix this behavior.

I now completely rely on generator-gulp-angular to inject the files. I will test it for a few day to see how everything is working and publish it, but feel free to help me and test it your self :)

doronsever commented 9 years ago

Published new version, Please check it out; I'm closing this issue, if you still have problems reopen this task again