jax
jax

Reputation: 38583

Turn off uglification for require.js third party code

Here is my require.js configuration for the optimizer.

({
      appDir: 'app/'
    , baseUrl: 'js'
    , mainConfigFile: 'app/js/main.js'
    , dir: 'build/'
    , modules: [{ name: 'main' }]
})

I have a folder in my project that contains third party dependencies called bower_components

When I run the require.js optimizer it iterates though every .css and .js file in these third party dependencies and uglifies them. The trouble is that I am already referring to the correct *.min.js file in my code. This takes a long time and I want to exclude the entire folder form uglification, however, I still want to to combine the third party dependencies into a single file where appropriate.

How can I achieve this?

Upvotes: 3

Views: 409

Answers (1)

tylerargo
tylerargo

Reputation: 1010

To turn off uglifying the code, add this line to your Javascript build configuration file:

    optimize: "none",

From the example.build.js docs:

    //How to optimize all the JS files in the build output directory.
    //Right now only the following values
    //are supported:
    //- "uglify": (default) uses UglifyJS to minify the code.
    //- "uglify2": in version 2.1.2+. Uses UglifyJS2.
    //- "closure": uses Google's Closure Compiler in simple optimization
    //mode to minify the code. Only available if running the optimizer using
    //Java.
    //- "closure.keepLines": Same as closure option, but keeps line returns
    //in the minified files.
    //- "none": no minification will be done.
    optimize: "uglify",

Here's a link to an example of all the build configuration options.

Upvotes: 1

Related Questions