This time I will show you how to use babel in Webstorm to convert ES6 to ES5, and how to use babel in Webstorm to convert ES6 to ES5.What are the precautions?The following is a practical case, let’s take a look take a look.
Foreword: ECMAScript 6 is the next generation standard of theJavaScriptlanguage, which was officially released in June 2015. Mozilla will launch JavaScript based on this standard 2.0. The goal of ES6 is to enable the JavaScript language to be used to write large and complex applications and become an enterprise-level development language. However, modern browsers do not have high support for the new features of ES6, so if you want to use the new features of ES6 directly in the browser, you must use other tools.
Today I will share how to configure Webstorm to use babel to automatically transcode ES6 to ES5. Babel is a widely used transcoder. Babel can perfectly convert ES6 code to ES5 code, so we can use ES6 features in our projects without waiting for browser support.
1. Create a new empty project in Webstorm and name it es6demo.
2. Then create a new package.json under the root directory, and only need to specify twoattributes, namely name and version.
3. Open the webstorm terminal (Terminal), the shortcut key is Alt F12,Installbabel-cli. It can also be installed globally.
Install babel-cli: npm install --save-dev babel-cli
4. After installing babel-cli, you can see that a node_modules file and a package-lock.json file are newly generated. At the same time, it is found that there is an extra
"devDependencies": { "babel-cli": "^6.26.0" }
npm install --save-dev babel-preset-es2015
{ "presets": [ "es2015" ] }
How to add a progress bar to uploaded images in axios
How to optimize the JSON data grouping of JS
JS operates TXT text to insert content at the specified position
The above is the detailed content of How to use babel to convert ES6 to ES5 in Webstorm. For more information, please follow other related articles on the PHP Chinese website!