Home > Development Tools > phpstorm > How to set up babel compilation under phpstorm

How to set up babel compilation under phpstorm

藏色散人
Release: 2021-03-18 18:18:49
forward
2043 people have browsed it

The following tutorial column of phpstorm will introduce to you how to set up babel compilation under phpstorm. I hope it will be helpful to friends in need!

How to set up babel compilation under phpstorm

Set up babel compilation under phpstorm

Use extension tools to directly compile babel under phpstorm, mainly for jsx Compile without introducing browser.min.js. It is useful for learning reactjs. It took a lot of detours for beginners to understand it. I hope it will be helpful to beginners. The following are the configuration steps:

First, install I won’t talk about nodejs and phpstorm. Check the official website;

Then, npm install babel babel-cli babel-preset-es2015 babel-preset-react
(note that you don’t need to care whether it is a global installation or not, nodejs You can also choose to install it on the d e f disk...)

Open phpstorm, click file->setting->tools->External tools in the upper left, and then click the plus sign above to add a new extension tool:

How to set up babel compilation under phpstorm

Fill in the extension tool name BABEL. Without further ado, the following configuration is as shown above. Click OK after configuration.

After the configuration is completed, start setting the shortcut keys for babel running: go back to the setting to search for key, click keymap:

Enter External tools->BABEL (the name of the babel compilation tool), double-click add keyboard shortcut settings (I use Alt n, as long as the shortcut keys do not conflict)
The last step is to open the jsx file and run Alt n:

How to set up babel compilation under phpstorm

The generated js file is in Quote it in the html page, and then open the browser to see the effect. Configuring babel-preset-es2015 is the same method, using different shortcut keys.

Only if you have a certain understanding of reactjs can the configuration method in this article be used properly (^__^) (it is also applicable under webstorm).

The above is the detailed content of How to set up babel compilation under phpstorm. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template