OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce I can not add my own js using requirejs

This topic contains 3 replies, has 3 voices, and was last updated by  onechyporenko 6 years, 6 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #32126

    Ayman Hussein
    Participant

    I am trying to add my own js using requirjs, i did the following steps:

    I created inside myBundle/Resources/config/requirejs.yml file set the following options:

    config:
    shim:
    ‘jquery-ui’:
    deps:
    – ‘jquery’
    ‘underscore’:
    exports: ‘_’
    ‘backbone’:
    deps:
    – ‘underscore’
    – ‘jquery’
    exports: ‘Backbone’
    paths:
    ‘jquery’: ‘../js/layout/my_theme/js/jquery-3.2.1.min.js’
    ‘jquery-ui’: ‘bundles/oroui/lib/jquery-ui.js’
    ‘bootstrap’: ‘bundles/oroui/lib/bootstrap.js’
    ‘../js/layout/my_theme/js/scripts.js’: ‘../js/layout/my_theme/js/scripts.js’

    and run this command: php app/console oro:requirejs:build

    and the build command create oro.min.js inside my theme folder and i included this fild inside my theme but i can not see my js functions in oro.min.js file.

    what am i missing?


    arh922

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #32127

    Nikita Makarov
    Participant

    Hello, Arh922.

    From given YML-code unable to see if formatting is correct, please use a code snippet to keep code formatting.

    Also please follow next documentation and let to know what steps are done https://github.com/oroinc/platform/tree/master/src/Oro/Bundle/RequireJSBundle

    #32128

    Ayman Hussein
    Participant

    arh922

    #32129

    onechyporenko
    Participant

    You change config file placed in “/Resources/config/requirejs.yml” – this is whole application config and it will be built into “web/js/oro.min.js” file, not in your theme file.

    Frontend config stored into “/Resources/views/layouts/{your_theme}/config/requirejs.yml”. Scripts from this config will be built into “oro.min.js” in your theme.

    In OroCommerce <= 1.3 we generate “oro.min.js” for each theme but we don’t use it. On both admin and frontend we use /web/js/oro.min.js file generated by .

    In 1.4 we will use “/Resources/config/requirejs.yml” files for admin and “/Resources/views/layouts/{your_theme}/config/requirejs.yml” for your theme on frontend.

    So, check please your scripts into “web/js/oro.min.js” and change configuration paths from

    ‘../js/layout/my_theme/js/scripts.js’: ‘../js/layout/my_theme/js/scripts.js’

    to

    ‘{mybundle}/js/layout/my_theme/js/scripts.js’: ‘/bundles/{mybundle}/js/layout/my_theme/js/scripts.js’

    where {mybundle} is a public folder of your bundle(company name + bundle name), you should see this folder inside “/web/bundles/” after “php app/console assetic:dump” command.

Viewing 3 replies - 1 through 3 (of 3 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

Back to top