Use ECMAScript 6+ in your theme
Version: 1.9
To prevent having cross-browser JavaScript problems, SXA comes with an ES watcher. This way, developers can use ECMAScript 6+ in their code, and also make it work in older browsers. ECMAScript 6+ code in the sources
folder is automatically converted file to a file in the scripts
folder to offer fallback functionality in older browsers.
To add an ECMAScript 6+ script class:
-
Store ECMAScript 6+ code in the
sources
folder of your theme:Media Library/MyTheme/sources
-
Start the default gulp task. The ES watcher now ensures that any ECMAScript 6+ code in the source folder are transformed to JavaScript code and saved in the
scripts
folder.