RequireJS skip certain files during optimization

I using requirejs, roptimizer, and grunt to run the tasks to optimize my angularjs application.

I'm building all my js's to one file for the time being using the following config:

({
    name: 'main',
    out: 'app.min.js',
    insertRequire: ['main'],
    wrap: true,
    separateCSS: true,
    mainConfigFile: 'main.js',
    preserveLicenseComments: false,
    optimize: 'uglify2',
    uglify2:{
        mangle: false
    },
    include: ['lib/require/require']
})

I also use a grunt task called html2js to compile all my HTML templates for angular to JavaScript to save downloads in production.

Problem is when I include these files in my build the optimizer messes them up and they no longer run correctly. The way its setup I need them to be dropped in after angularjs but before anything else.

Including the files after my app.min.js file in the HTML page also does not work because I have to register the module like: app.requires.push('templates-main');

Is it possible to have r-optimizer skip this file during optimization but still include it in the app.min.js file?

Answers


In the require build config, add the filename followed by 'empty' like:

 compile: {
     options: {
         paths: {
             'templates':'empty:',
         }
      }
  }

Need Your Help

How can INFO and DEBUG logging message be sent to stdout and higher level message to stderr

python logging

Is there an easy way with python's logging module to send messages with a DEBUG or INFO level and the one with a higher level to different streams?

Is typedeffing templated base class to simplify the code a good practice?

c++ templates

I caught myself "inventing" this simple construct lately when working with many templated classes and deriving from them. I am not sure if it is common practice, or am I tying a rope around my neck.