Oracle JET uses Requirejs third-party tools or libraries to introduce

Source: Internet
Author: User

Use Requirejs to add third-party tools or libraries in Oracle JET applications.

Steps:

1. If you use a tool frame scaffold, you need to do it.

A. Use NPM to install the libraries you need.

NPM Install My-library--save

B. In the Script/grunt/config directory, locate the copycustomlibstostaging update code in the Oraclejet-build.js.

Remove the note. and change:

copycustomlibstostaging: {    fileList: [              {cwd:' node_modules/my-library/',               src: [' * ' ],               ' web/js/libs/my-library ' }              ]},

C. In the Src/js directory, add a new library to the Main-release-paths.json file. Use the min version. This file is used when building the release.

{    "knockout": "libs/knockout/knockout-x.x.x",    "jquery": "Libs/jquery/jquery-x.x.x.min" ,    ... contents omitted    "my-library": "Libs/my-library/my-library.min"}

2. If you are not building using the tool framework, add new libraries and accompanying files directly to the Js/libs directory.

3. After performing the previous step, use Requierjs to add a path to Requirejs.config in Main.js and define it in require if needed.

Requirejs.config ({//add a path to a new librarypaths: {' Knockout ': ' libs/knockout/knockout-3.4.0 ',    ' jquery ': ' Libs/jquery/jquery-3.1.0.min ',... contents omitted' Text ': ' Libs/require/text ',    ' my-library ': ' libs/my-library/my-library }, //If it is not an AMD module, add the content required for the new library here Shim: {' jquery ': {exports: [' JQuery ', ' $ ']}}, require ([' Ojs/ojcore ', ' knockout ', ' jquery ', 'my-library‘],function(OJ, KO, $)//callback function that executes after all modules have been loaded  {      //Add use code here  });

Oracle JET uses Requirejs third-party tools or libraries to introduce

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.