├── README.md └── build.js /README.md: -------------------------------------------------------------------------------- 1 | # magento-rjs-config 2 | 3 | **NOTE** This readme is deprecated. See https://devdocs.magento.com/guides/v2.3/performance-best-practices/advanced-js-bundling.html 4 | 5 | **NOTE** Configuration generation tool that automates build.js creation was created by Shane Osbourne: https://github.com/WeareJH/config-gen 6 | 7 | This `r.js` build file is built for Magento 2.2.0-rc30 CE Luma theme. 8 | 9 | **NOTE**: Manual modification of the `build.js` file for your project IS NOT REQUIRED. A major benefit will be achieved by any `Magento/blank` or `Magento/luma`-based installation with this build configuration without the need for any modifications. Tweaking the `build.js` file is optional if you want to achieve 100% improvements. 10 | 11 | The Magento 2 built-in bundler relies only on PHP, which is not very efficient and could lead to potential issues. The build file `build.js` from this repository can be used to execute bundling and minification on deployed static content with the `r.js` tool shipped with the NPM version of RequireJS. It will optimize the main pages of Magento 2. 12 | 13 | The process described here should be applied only during deployment to production. 14 | 15 | ## Usage 16 | * Install [r.js](http://requirejs.org/docs/optimization.html) 17 | * Download `build.js` from this repo 18 | * Edit `build.js` to remove/add files from your custom theme to bundles (optional) 19 | * Apply [the jquery.cookie issue patch](#fixing-missconfiguration-of-jquerycookie) 20 | * Run `magento setup:static-content:deploy` to deploy Magento 2 static content to `{magentoDir}/pub/static/` folder 21 | * For every theme locale that you use: 22 | * Move `{magentoDir}/pub/static/{area}/{vendor}/{theme}/{locale}` folder to `{magentoDIr}pub/static/{area}/{vendor}/{theme}/{locale}_source` 23 | * Run `r.js -o build.js baseUrl={magentoDir}/pub/static/{area}/{vendor}/{theme}/{locale}_source dir={magentoDir}/pub/static/{area}/{vendor}/{theme}/{locale}` 24 | 25 | ## Output 26 | * Bundles all files common for all Magento 2 Luma storefront pages into `requirejs/require.js` file 27 | * Generates 5 page-specific bundle files: 28 | * `bundles/default.js` - should be added to `default` layout handle 29 | * `bundles/cart.js` - should be added to `checkout_cart_index` layout handle 30 | * `bundles/checkout.js` - should be added to `checkout_index_index` layout handle 31 | * `bundles/catalog.js` - should be added to `catalog_category_view` and `catalog_product_view` layout handles 32 | * `bundles/product.js` - should be added to `catalog_product_view` layout handle 33 | 34 | ### Adding bundles to pages 35 | To add a bundle file to the corresponding page, add following instruction to the page layout update file in your module: 36 | ```xml 37 | 38 |