3

I have many javascripts files (using requirejs) which I want to combine.

There are many asset manangements apps and it is hard to know which tool is right one for me.

For instance, I'm not sure how I could use django-pipeline to combine javascripts files since

I have require(['some-dependency'], function(dependency) {
instead of <script type="text/javascript" src="somefile.js"></script>

I suspect that django-require is able to optimize requirejs-using javascripts since django-require states that it optimizes using requriejs.
But it's hard to know how to do it from their doc.

1 Answer 1

2

I had similar problems with combining different Django apps for more complex frontend tasks. I ended up using Grunt and Bower along side Django and don't regret that at all.

I actually gave a talk on this a week ago at Django Stockholm meet up, the slides are available here to get you started: https://volumental-public-downloads.s3.amazonaws.com/django_and_a_modern_frontend_django_meetup_2014.pdf

To use Grunt to run your requirejs build you would use the Grunt plugin: https://www.npmjs.org/package/grunt-contrib-requirejs

I found this to be a good resource to set everything up for requirejs and grunt: Working project structure that uses grunt.js to combine JavaScript files using RequireJS?

Best of luck!

Sign up to request clarification or add additional context in comments.

3 Comments

I looked at your slide and grunt-contrib-requirejs. fascinating. but it fails me in one aspect.. Some Django apps have static files. and since r.js works with file path, it's hard to access your virtualenv/..libs../3rdparty-lib/../static/ folder. I guess that's why I couldn't find a single webpage which deals with django + requirejs + grunt.
github.com/skibblenybbles/django-grunt I guess this tries to address that..
I have been using Grunt & Bower for frontend dependencies on a couple of Django (and otherwise) projects and would advise people to be wary. I have found that it can require an awful lot of additional learning and time to get set up right. I'd advise people to make sure they need (and are willing to maintain) the added overhead of a totally separate stack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.