1
votes

Require.js optimizer r.js with follow configuration just copies files to appDir/distr without any optimizations (concatenation, compress, uglify):

({
  appDir: "../",
  baseUrl: "./",
  dir: "../distr",
  optimizeCss: "standard",
  modules: [
      {
          name: "js/main"
      }
  ],

  paths: {
    jquery: 'js/libs/jquery/jquery-2.0.3.min',
    jquery_cookie: 'js/libs/jquery/jquery.cookie-1.3.1',
    underscore: 'js/libs/underscore/underscore-1.5.1',
    backbone: 'js/libs/backbone/backbone-1.0.0',
    marionette: 'js/libs/backbone/backbone.marionette-1.0.4',
    text: 'js/libs/require/text-2.0.10',
    Handlebars: 'js/libs/handlebars/handlebars-1.0.0',
    handlebars_helpers: 'js/libs/handlebars/helpers',
    hbs: 'js/libs/require/hbs-0.4.0',
    'hbs/underscore': 'js/libs/require/hbs/underscore',
    'hbs/i18nprecompile': 'js/libs/require/hbs/i18nprecompile',
    'hbs/json2': 'js/libs/require/hbs/json2',
    bootstrap: 'js/libs/bootstrap/bootstrap.min',
    jquery_typing: 'js/libs/jquery/jquery-typing-0.2.0',
    'template/helpers/ifCond': 'js/libs/handlebars/helpers',
    'template/helpers/ifNull': 'js/libs/handlebars/helpers'
  },
  shim: {
    underscore: {
        exports: '_'
    },
    backbone: {
        deps: ['underscore', 'jquery'],
        exports: 'Backbone'
    },
    marionette: {
      deps: ['backbone'],
      exports: 'Marionette'
    },
    Handlebars: {
      exports: 'Handlebars'
    },
    handlebars_helpers: {
      exports: 'Handlebars'
    },
    bootstrap: {
      deps: ['jquery'],
      exports: 'Bootstrap'
    }
  },
  hbs : {
      templateExtension : 'html',
      disableI18n : true
  }
})

I run optimizations with:

node ./r.js -o ./js/build.js

It copies all files from appDir to appDir/distr and traces:

# node ./r.js -o ./js/build.js
Optimizing (standard) CSS file: /home/www/myproject.local/distr/css/bootstrap.min.css
Optimizing (standard) CSS file: /home/www/myproject.local/distr/css/styles.css
Tracing dependencies for: js/main
# 

Why optimization of js-files don't work?

1
are you running this on a window os? It looks like you have errors but r.js does not report them well. I worked on cygwin terminal and all my r.js errors were suppressed.ekeren
I run it on ubuntu. Some reasons was in Handlebars helpers, I disabled them all and build was done successfully. Now I try to make Handlebars helpers work.psylosss
Did you try my solution?ekeren
Yes, but no effect. I exploded my single helpers js-file to per-helper-file (like in github.com/SlexAxton/require-handlebars-plugin) with removing whole "handlebars_helpers" section in config. All works fine!psylosss
Solved. I executed it on Ubuntu running as guest in Virtualbox. But symlinks did not work properly. I replaced shared virtualbox folder with Samba-shared folder (where symlinks are available), and now it works.psylosss

1 Answers

0
votes

handlebars_helpers should be dependent on Handelbar:

handlebars_helpers: {
  exports: 'Handlebars'
  deps: ['Handelbar'],
},