Skip to content

grunt serve:dist not concated all of app.js #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kageetai opened this issue Aug 26, 2014 · 39 comments
Closed

grunt serve:dist not concated all of app.js #491

Kageetai opened this issue Aug 26, 2014 · 39 comments
Labels

Comments

@Kageetai
Copy link

Hi there,

I tried out your generator for a project and am generally very happy with it. But after working on it for a while and several commits to my project, I wanted to try out deploying to Heroku and ran grunt serve:dist but when the process ran through and the browser window opens I notice several 404s for all the apps script files. After looking into the generated index.html in distI saw that the said files don't seem to get put into the minified app.js like here:

<script src="app/93e24447.vendor.js"></script>

        <!-- build:js({.tmp,client}) app/app.js -->
        <script src="app/cf3a9943.app.js"></script>
          <!-- injector:js -->
          <script src="app/account/account.js"></script>
          <script src="app/account/login/login.controller.js"></script>
          <script src="app/account/settings/settings.controller.js"></script>
          <script src="app/account/signup/signup.controller.js"></script>
          <script src="app/admin/admin.controller.js"></script>
          <script src="app/admin/admin.js"></script>
          <script src="app/main/main.controller.js"></script>
          <script src="app/main/main.js"></script>
          <script src="components/auth/auth.service.js"></script>
          <script src="components/auth/user.service.js"></script>
          <script src="components/mongoose-error/mongoose-error.directive.js"></script>
          <script src="components/navbar/navbar.controller.js"></script>
          <!-- endinjector -->
        <!-- endbuild -->

I generated a new project with the generator again and everything works fine. So I checkout out my very first commit in my project, where I just commited the unchanged code the yeoman generated. Still the same problem!
I even compared both projects file by file now and besides the names (and hashes of course) there are now differences in them at all!

Does anyone know about this problem and can help me out?

@zerdos
Copy link

zerdos commented Aug 27, 2014

the same problem here. The vendor.js file is in the dist folder. Investigating.

@Kageetai
Copy link
Author

I even have an app.js file there too, but apparently without the files listed above in it.

@kingcody
Copy link
Member

Hmm, are you guys running the latest version of the generator?

@zerdos
Copy link

zerdos commented Aug 28, 2014

How can we check?

@kingcody
Copy link
Member

Haha, hopefully npm update -g generator-angular-fullstack was all you needed

@kingcody
Copy link
Member

I see; in bash, I do: npm list -g | grep fullstack

@zerdos
Copy link

zerdos commented Aug 28, 2014

$ npm list -g | grep fullstack
├─┬ [email protected]

@kingcody
Copy link
Member

That is the current version. Does the issue occur with a freshly generated project?

@zerdos
Copy link

zerdos commented Aug 28, 2014

Yep.
$ yo angular-fullstack testapp
$ grunt
$ cat dist/public/app/d41d8cd9.vendor.js | wc -l
0

@kingcody
Copy link
Member

Odd, mind posting your .yo-rc.json in a gist for me? I'll see if I can reproduce.

@zerdos
Copy link

zerdos commented Aug 28, 2014

{
  "generator-angular-fullstack": {
    "insertRoutes": true,
    "registerRoutesFile": "server/routes.js",
    "routesNeedle": "// Insert routes below",
    "routesBase": "/api/",
    "pluralizeRoutes": true,
    "insertSockets": true,
    "registerSocketsFile": "server/config/socketio.js",
    "socketsNeedle": "// Insert sockets below",
    "filters": {
      "js": true,
      "html": true,
      "sass": true,
      "uirouter": true,
      "bootstrap": true,
      "uibootstrap": true,
      "mongoose": true
    }
  },
  "generator-ng-component": {
    "routeDirectory": "client/app/",
    "directiveDirectory": "client/app/",
    "filterDirectory": "client/app/",
    "serviceDirectory": "client/app/",
    "basePath": "client",
    "filters": [
      "uirouter"
    ],
    "extensions": [
      "js",
      "html",
      "scss"
    ],
    "directiveSimpleTemplates": "",
    "directiveComplexTemplates": "",
    "filterTemplates": "",
    "serviceTemplates": "",
    "factoryTemplates": "",
    "controllerTemplates": "",
    "decoratorTemplates": "",
    "providerTemplates": "",
    "routeTemplates": ""
  }

@kingcody
Copy link
Member

In client/index.html, change line 47 from:

    <!-- build:js({client}) app/vendor.js -->

to:

    <!-- build:js(client) app/vendor.js -->

No braces.
*
Note: Line 47 on a new project

@Kageetai
Copy link
Author

Hey,
I used an slightly older version of the generator for the project and it works with a newly generated one.
And furthermore a misssing app/vendor.js is not even my problem as described above, but not all files under <!-- build:js({.tmp,client}) app/app.js --> get injected in the generated app/app.js.
I don't really want to restart the project with the newer generator so is there a way to fix that?

@Kageetai
Copy link
Author

Just noticed my something:

cat dist/public/app/cf3a9943.app.js | wc -l
      0

@kingcody
Copy link
Member

What version of the generator did you use to begin with?

@Kageetai
Copy link
Author

I am currently at work and started the project at home. I think it was the version right before you added grunt-build-control
Btw, here is my project, if it helps: https://github.com/Kageetai/JayMap

@kingcody
Copy link
Member

You can TRY to rebase on to a newer version of the generator.
To create a new branch for the new generator app base:
git checkout --orphan newbase && git rm --cached -r .

Then delete all the files and folders in that branch and regenerate the app with the same settings and commit the changes in the newbase branch. Then create another branch to test the rebase in:
git checkout -b test-rebase master

Then rebase test-rebase onto newbase:
git rebase newbase

You may have to resolve conflict errors, git status will be your friend.

@Kageetai
Copy link
Author

Okay, that's a new concept in git for me, but I will try it out this evening.

@kingcody
Copy link
Member

Sounds good. You can read up on git rebase here if you'd like to know more :)

@Kageetai
Copy link
Author

I knew rebasing in concept but rarely used it before :)

okay the test-rebase branch seems to work so far...
Are there any best practices to get test-rebase back into master now? Merging or rebasing, what is better?

@kingcody
Copy link
Member

So if everything works you can just rebase master onto newbase just like you did with test-rebase. That would probably be the best thing to do.

@Kageetai
Copy link
Author

Okay, the same problem came up again after I redid my changes and tried to prepare for deploying to heroku. I think I'm gonna try and restart it all with the newer generator from grounds up...

@Kageetai
Copy link
Author

Oh dang, the problem just came back totally randomly!
I have no idea anymore what that could be.
This is the output I get in the console when running grunt serve:dist (shop is one of my models)

Running "wait" task
>> Waiting for server reload...
Done waiting!

Running "open:server" (open) task

Running "express-keepalive" task
GET /app/account/account.js 404 29ms
GET /app/account/login/login.controller.js 404 12ms
GET /app/account/settings/settings.controller.js 404 11ms
GET /app/account/signup/signup.controller.js 404 8ms
GET /app/admin/admin.controller.js 404 7ms
GET /app/admin/admin.js 404 21ms
GET /app/main/main.controller.js 404 19ms
GET /app/main/main.js 404 19ms
GET /app/shop/geocode.service.js 404 17ms
GET /app/shop/new/new.controller.js 404 21ms
GET /app/shop/new/new.js 404 12ms
GET /app/shop/shop.controller.js 404 11ms
GET /app/shop/shop.js 404 14ms
GET /components/auth/user.service.js 404 15ms
GET /components/auth/auth.service.js 404 16ms
GET /components/mongoose-error/mongoose-error.directive.js 404 6ms
GET /components/navbar/navbar.controller.js 404 10ms
GET /api/shops 304 17ms

Oh, and I am on version 2.0.12 now...

@DaftMonk
Copy link
Member

Hmm it might be that scripts aren't getting injected on the dist build. This probably wont help, but it might be worth a try:

Comment out injector from the jit-grunt in your gruntfile:

  require('jit-grunt')(grunt, {
    express: 'grunt-express-server',
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn',
    protractor: 'grunt-protractor-runner',
//    injector: 'grunt-asset-injector', <--- remove
    buildcontrol: 'grunt-build-control',
    istanbul_check_coverage: 'grunt-mocha-istanbul'
  });

Then do npm install --save-dev grunt-injector

Try building it again.

@Kageetai
Copy link
Author

Nope, that didn't work unfortunately. Didn't suspected that anyway as it worked a while ago...

@Kageetai
Copy link
Author

The strangest thing is, even if I clone the whole repository and immediatly check out the first commit (where the ´grunt serve:dist´ first worked) it doesn't work anymore...

@kingcody
Copy link
Member

@Kageetai just wondering where you were on this? Any progress?

@Kageetai
Copy link
Author

Hi couldn't do much for it the last weeks but want to try more the next days. The problem still occurred and I don't know why. I will try to restart the project from the generator and not include running the Mongo server with grunt, although I don't really think that's the problem...

@vincentdo
Copy link

Not sure if this is a related problem but my main.html view doesn't seem to be loaded on

grunt serve:dist

but works just fine on

grunt serve

@ghost
Copy link

ghost commented Oct 3, 2014

Any further progress on this? I'm having a similar issue and I can't seem to figure it out for the life of me.

@Kageetai
Copy link
Author

Kageetai commented Oct 9, 2014

Unfortunately no progress on the problem, as I didn't have time to do something and are in vacation now. But will do more when I get back to it

@JaKXz JaKXz added the question label Oct 9, 2014
@Meg4mi
Copy link

Meg4mi commented Oct 28, 2014

Hi there,

I've encountered xactly the same problem here.
After hours of file by file comparison.
I've finally solved it. So I thought I would share what has worked for me.

I'm working on windows, and simply change the line ending to Unix style for "index.html" in my text editor (I'm using sublime text by the way) solve the problem. "Windows" line ending make the script bug it seems.

Hope that will help.

Meg4mi

@bnns
Copy link

bnns commented Oct 28, 2014

I was having this issue for a long time, and @Meg4mi's solution worked. Thanks a lot!

In Webstorm, I opened index.html and then did File -> Line Separators -> LF (Unix style), then ran grunt serve:dist again.

@Kageetai
Copy link
Author

Oh wow!!
That Seems to work for me too!
That you a fecking lot! This never ocured to me!

@kingcody
Copy link
Member

Hey, that's awesome guys! I'm wondering if we should use the validateLineBreaks option in jscs to help catch this in the future.

Also, github has a pretty decent write up on handling line endings in a project, if anybody would like some extra documentation: https://help.github.com/articles/dealing-with-line-endings/

@Kageetai
Copy link
Author

I just stumbled upon that again in another project. Any progress on integrating that into the generator?

@Awk34
Copy link
Member

Awk34 commented Jul 14, 2015

@Kageetai .editorconfig and .jscsrc in canary validate line breaks

@Awk34 Awk34 closed this as completed Jul 14, 2015
@Lo5t
Copy link

Lo5t commented Sep 17, 2015

+1

@rkumar1904
Copy link

Hey @Meg4mi That's awesome !

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

No branches or pull requests