Important

You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

JavaScript

Javascript in OroCommerce has a modular architecture based on Chaplin and Backbone.

See also

JavaScript Frontend Architecture covers the client-side architecture of OroPlatform-based applications including OroCommerce.

This section provides configuration reference for the Webpack library to enable a modular structure of JS components in Oro applications.

JS Modules Definition

JS modules configuration file should be placed in the Resources/views/layouts/{theme_name}/config folder and named jsmodules.yml, for example DemoBundle/Resources/views/layouts/base/config/jsmodules.yml.

Entry point for Webpack build is oroui/js/app. But you can change it providing the same alias to the necessary entry point.

Example:

 1# src/Acme/Bundle/DemoBundle/Resources/views/layouts/base/config/jsmodules.yml
 2shim:
 3    jquery:
 4        expose:
 5            - $
 6            - jQuery
 7    jquery.form:
 8        imports:
 9            - jQuery=jquery
10map:
11    '*':
12        'jquery': 'oroui/js/jquery-extend'
13    'oroui/js/jquery-extend':
14        'jquery': 'jquery'
15aliases:
16    'jquery$': 'oroui/lib/jquery-1.10.2'
17    'jquery-ui$': 'oroui/lib/jquery-ui.min'
18    'oroui/js/app$': 'acmedemo/js/app'