minification and injection

134 views
Skip to first unread message

Romuald Quantin

unread,
Jun 3, 2013, 6:29:13 AM6/3/13
to som...@googlegroups.com
I need to write more doc about how to minify and keep the injection from falling apart. But for now, here are some information.

The tool used to minify usually rename all variables, it can a problem with dependency injection frameworks, such as soma.js or angular.

If you are using uglify which is probably the most common tool, you can use an option called "mangle", which can either be set to false not to rename any variables, or can take an array of exception as a parameter.

See the --no-mangle option:

If you are using Grunt, it is even easier:

Here is an example with the soma-template plugin, where the 2 injection names "injector" and "instance" are protected:

I suggest you turn the option to false (mangle: false, no array), and optimize with a list of exception at a later point.

Hope that helps!

Romu

Romuald Quantin

unread,
Jun 3, 2013, 6:34:31 AM6/3/13
to som...@googlegroups.com
Another addition if you are using require.js with r.js and grunt, the mangle can be turned off that way:

requirejs: {
                   compile: {
                             options: {
                                     uglify:{
                                               mangle: false

Reply all
Reply to author
Forward
0 new messages