Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Replace RequireJS with Almond during build #300

Closed
wants to merge 1 commit into from

Conversation

marian-r
Copy link
Contributor

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
Copy link

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
Copy link
Contributor Author

marian-r commented Jan 8, 2015

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

@rszczypka
Copy link

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
Copy link
Contributor Author

marian-r commented Jan 8, 2015

Have you copied all my changes to your Gruntfile?

@marian-r
Copy link
Contributor Author

marian-r commented Jan 8, 2015

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
Copy link

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
Copy link
Contributor Author

marian-r commented Jan 9, 2015

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
Copy link

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
Copy link

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
Copy link

jde commented Mar 13, 2015

Thanks for working on this fix. Looks like this is the first move to resolving #299 and #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
Copy link
Contributor Author

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
Copy link

Hey y'all! Please merge re: yeoman/grunt-usemin#112

@kevva
Copy link
Member

kevva commented Jun 2, 2015

This needs a rebase.

@marian-r
Copy link
Contributor Author

marian-r commented Jun 2, 2015

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

@kevva
Copy link
Member

kevva commented Jun 4, 2015

You are.

@marian-r marian-r force-pushed the requirejs-almond branch from a78c348 to be199c3 Compare June 5, 2015 10:41
@marian-r
Copy link
Contributor Author

marian-r commented Jun 5, 2015

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

@kevva
Copy link
Member

kevva commented Jun 6, 2015

Looks good :).

@marian-r
Copy link
Contributor Author

Any progress?

@kevva
Copy link
Member

kevva commented Jun 16, 2015

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
Copy link
Member

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
Copy link
Member

kevva commented Jun 16, 2015

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

@arthurvr
Copy link
Member

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

Totally 👍!

@addyosmani
Copy link
Member

I'm 👍 call for a maintainer

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

Successfully merging this pull request may close these issues.

9 participants