Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to exclude certain requireJS files from uglifying/optimizing
    primarykey
    data
    text
    <p>I have a working requirejs project that is using grunt for building and deployment. If using no optimization at all, the build is working without problems and I get one big js file to deploy it on production.</p> <p>The problem I have is, that I have some external frameworks (like angularJS) where I already have a minimized/optimized version of it and don't want to optimize it again. </p> <p>Currently without optimization I include the minified version of this framework via a seperate path config in my gruntfile. Whereas in my normal main.js I have the non-minified version for development.</p> <p>Now I want to use the optimizer to optimize my own code, but to NOT optimize the external frameworks. But the external frameworks should be included in the resulting big javascript file. Basically I want to tell the optimizer that he should use the original file in some cases. </p> <p>Can I do it something like this? </p> <p>I only have found a global exclude option, so that some modules are not included in the resulting optimized js at all. </p> <p>This is my grunt configuration:</p> <pre><code>requirejs: { compile: { options: { baseUrl: "&lt;%= pkg.folders.jsSource %&gt;", name: "../external-libs/almond-0.1.1", include: "main", mainConfigFile: "&lt;%= pkg.folders.jsSource %&gt;/main.js", out: "&lt;%= pkg.folders.build + pkg.name + '-' + pkg.version %&gt;/js/main.js", //logLevel: 0, optimize: "uglify2", //optimize: "none", paths: { 'angular':'../external-libs/min/angular-1.0.4', 'jquery':'../external-libs/min/jquery-1.7.2', 'jquery.mobile':'../external-libs/min/jquery.mobile-1.2.0', 'adapter': '../external-libs/min/jquery-mobile-angular-adapter-1.2.0', 'moment': '../external-libs/moment-1.6.2.min', 'iscroll': '../external-libs/min/iscroll-4.2.5', 'iscrollview': '../external-libs/min/jquery.mobile.iscrollview-1.2.6', 'add2Home': '../external-libs/min/add2home', 'config/config': "config/&lt;%=configDatei%&gt;" } } } }, </code></pre> <p>And this is the relevant part of the main.js: </p> <pre><code>require.config({ paths:{ 'angular':'../external-libs/angular-1.0.4', 'jquery':'../external-libs/jquery-1.7.2', 'jquery.mobile':'../external-libs/jquery.mobile-1.2.0', 'adapter': '../external-libs/jquery-mobile-angular-adapter-1.2.0', 'moment': '../external-libs/moment-1.6.2.min', 'iscroll': '../external-libs/iscroll-4.2.5', 'iscrollview': '../external-libs/jquery.mobile.iscrollview-1.2.6', 'add2Home': '../external-libs/add2home' }, shim:{ 'angular':{ deps:['jquery'], exports:'angular' }, 'iscroll':{ deps:['jquery'], exports:'iscroll' }, 'iscrollview':{ deps:['jquery.mobile', 'iscroll'], exports:'iscrollview' } } }); </code></pre> <p>Thanks for any help. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload