How to use the requirejs.optimize function in requirejs

To help you get started, we’ve selected a few requirejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhoukekestar / modules / optimizer.js View on Github external
var optimizeModules = function(index, callback) {

  if (index >= currentModules.length) {
    return callback(null, results);
  }
  config.name = currentModules[index];
  // console.log(config.name + ' is optimizing...');
  requirejs.optimize(config, function (buildResponse) {
    results += currentContent;
    return optimizeModules(index + 1, callback);
  }, function(err) {
    callback(err)
  });
}
github alberto-acevedo / cesium-navigation / Examples / build.js View on Github external
// This only builds the sources for the example amd.html
// all other examples do not need to be built.

var requirejs = require('requirejs');

var config = {
    baseUrl: '.',
    optimize: 'uglify2',
    mainConfigFile: 'Source/mainConfig.js',
    name: "Source/amd/main",
    out: "Build/amd.min.js",
    logLevel: 0
};

requirejs.optimize(config);
github gruntjs / grunt-contrib-requirejs / tasks / requirejs.js View on Github external
} catch (e) {
        grunt.fail.warn('There was an error while processing your done function: "' + e + '"');
      }
    };

    // The following catches errors in the user-defined `error` function and passes them.
    // if the error function options is not set, this value should be undefined
    var tryCatchError = function(fn, done, err) {
      try {
        fn(done, err);
      } catch (e) {
        grunt.fail.fatal('There was an error while processing your error function: "' + e + '"');
      }
    };

    requirejs.optimize(
            options,
            tryCatchDone.bind(null, options.done, done),
            options.error ? tryCatchError.bind(null, options.error, done):undefined
    );

  });
};
github AnalyticalGraphicsInc / cesium / gulpfile.js View on Github external
gulp.task('requirejs', function(done) {
    var config = JSON.parse(Buffer.from(process.argv[3].substring(2), 'base64').toString('utf8'));

    // Disable module load timeout
    config.waitSeconds = 0;

    requirejs.optimize(config, function() {
        done();
    }, done);
});
github erkobridee / lab-nodejs / js_until_es5.1 / bundlers / requirejs_build / node.js / 01 / build / lib / builder.js View on Github external
function builder( config ) {

  // config.out = outputConsole;
  requirejs.optimize(config, buildResponse, buildError);

}
github BorderTech / wcomponents / wcomponents-theme / build-js.js View on Github external
return new Promise(function(win, lose) {
		requirejs.optimize(conf, function (buildResponse) {
			noisyLog(buildResponse);
			console.timeEnd("buildJS");
			win();
		}, function(err) {
			console.error(err);
			lose(err);
		});
	});
}
github msdevstep / subroute.io / Subroute.App / lib / imagesloaded / gulpfile.js View on Github external
if ( file.isNull() ) {
      return cb( null, file );
    }

    options.logLevel = 2;

    options.out = function( text ) {
      var outFile = new gutil.File({
        path: file.relative,
        contents: new Buffer( text )
      });
      cb( null, outFile );
    };

    gutil.log('RequireJS optimizing');
    requirejs.optimize( options, null, function( err ) {
      var gulpError = new gutil.PluginError( 'requirejsOptimize', err.message );
      stream.emit( 'error', gulpError );
    });
  });
github c24w / try-catch-finally.js / build.js View on Github external
function build(config) {
	requirejs.optimize(
		config,
		console.log.bind(console),
		console.error.bind(console)
	);
}
github fbrctr / fabricator / tasks / compile-toolkit.js View on Github external
grunt.registerTask("compile-toolkit-js", "Build", function () {

		var done = this.async();

		requirejs.optimize(config, function (response) {
			grunt.log.writelns(response);
			done();
		}, function (err) {
			done(err);
		});

	});
github gist-run / gist-run / build / tasks / bundle.js View on Github external
function unbundle(name, done) {
  var config = {
    name: name + '-manifest',
    out: name + '.js',
    rawText: {},
    optimize: 'none'
  };
  config.rawText[name + '-manifest'] = 'define([], function() {});';

  Object.assign(config, configBase);
  rjs.optimize(config, () => done());
}

requirejs

Node adapter for RequireJS, for loading AMD modules. Includes RequireJS optimizer

MIT
Latest version published 5 months ago

Package Health Score

83 / 100
Full package analysis

Popular requirejs functions