yeoman / generator-backbone

Scaffold out a Backbone.js project
http://yeoman.io
638 stars 159 forks source link

Replace RequireJS with Almond during build #300

Closed marian-r closed 8 years ago

marian-r commented 9 years ago

What about replacing RequireJS with almond for app in production? This config works for me. R.js combines everything to one file in .tmp directory and uglify then minifies and moves the file to dist. Just, I've not tested it with CoffeScript, since I don't work with it.

rszczypka commented 9 years ago

Hi @marian-r, thanks for this changes. However, I'm getting an error when trying to build with your edited version of gruntfile.js:

Verifying property uglify.generated exists in config...ERROR
>> Unable to process task.
Warning: Required config property "uglify.generated" missing. Use --force to continue.

Would you be able to explain why this is happening?

marian-r commented 9 years ago

Do you have everything installed properly - Grunt, Node packages?

rszczypka commented 9 years ago

Yes, I have all of those installed and working. First I used

yo backbone

to start the app but I was getting the conflict with usemin and requirejs when doing the build with grunt. I found your solution and then changed my gruntfile.js as per your file, removed the usemin block comments around the

<script data-main="scripts/main" src="bower_components/requirejs/require.js"></script>

in index.html

and tried to build again

marian-r commented 9 years ago

Have you copied all my changes to your Gruntfile?

marian-r commented 9 years ago

I tried your workflow and it is working. Make sure you copied all the changed blocks especially the last one - build workflow. Also don't forget to remove one '%' character for config variables, i.e. <%%= yeoman.app %> -> <%= yeoman.app %>.

rszczypka commented 9 years ago

Thanks @marian-r for looking into it. This is my gruntfile.js and I can't see anything wrong with it: https://gist.github.com/rszczypka/b1eee1acb83774f9a30b

Maybe the problem is somewhere else. I am able to build without problem when I comment out the line

uglify:generated

from the build task and the output looks all right so I won't worry about this any more.

Thank you for you help!

marian-r commented 9 years ago

Your Gruntfile works for me. Maybe one more thing you can do is to send me the verbose output from grunt build grunt build --verbose.

jbhannah commented 9 years ago

There are a couple additional changes that need to be made for this to work with CoffeeScript—specifially, building the CoffeScript files into a separate temporary directory, then loading the main module from that location during the RequireJS step. In Gruntfile, in the coffee:dist configuration:

-                    dest: '.tmp/scripts',
+                    dest: '.tmp/coffee/scripts',

and in the requirejs:dist configuration:

-                    mainConfigFile: '<%= yeoman.app %>/scripts/main.js', // contains path specifications and nothing else important with respect to config
+                    paths: {'main': '../../.tmp/coffee/scripts/main'},
+                    mainConfigFile: '.tmp/coffee/scripts/main.js', // contains path specifications and nothing else important with respect to config
jbhannah commented 9 years ago

Actually, even better: instead of changing the CoffeeScript build output directory, change the requirejs:dist build output directory (dir) to .tmp/requirejs/scripts, and point uglify:dist to the main.js file there instead of in .tmp/scripts. Changing the CoffeeScript build output directory breaks grunt serve.

jde commented 9 years ago

Thanks for working on this fix. Looks like this is the first move to resolving https://github.com/yeoman/generator-backbone/pull/299 and https://github.com/yeoman/generator-backbone/pull/296, which resolves the out of the box bug preventing us from using a recent version of usemin. Looking forward to seeing this make it to master.

marian-r commented 9 years ago

I am a little bit surprised why the maintainers of this repo are not trying to make Grunt build working. But maybe my fix is not working for some scenarios which I didn't test.

In the meantime, you can try to use this fix by yourself.

charneykaye commented 9 years ago

Hey y'all! Please merge re: https://github.com/yeoman/grunt-usemin/issues/112

kevva commented 9 years ago

This needs a rebase.

marian-r commented 9 years ago

Am I suppose to do it, or you are? I am not sure what you mean.

kevva commented 9 years ago

You are.

marian-r commented 9 years ago

I've done the rebase. Please check if it's OK as I've done it for the first time.

kevva commented 9 years ago

Looks good :).

marian-r commented 9 years ago

Any progress?

kevva commented 9 years ago

I'm not really using this so I'm not the right one to test, but if someone else could and confirm it's working I'll be happy to merge.

arthurvr commented 9 years ago

I'm not really using this so I'm not the right one to test, but if someone else could and confirm it's working I'll be happy to merge.

@kevva I'm not the right one eighter and I don't think many of us (if any) uses generator-backbone extensively. The build system is broken in many ways and I saw people complaining about it on IRC already...

We don't have an active maintainer for this repo so we should probably discuss opening such a "call for a maintainer" issue.

kevva commented 9 years ago

Call for a maintainer or find a community alternative that we can deprecate this in favor of.

arthurvr commented 9 years ago

Call for a maintainer or find a community alternative that we can deprecate this in favor of.

Totally :+1:!

addyosmani commented 9 years ago

I'm :+1: call for a maintainer