Webpack Study notes Five

Source: Internet
Author: User

Babel is a few modular packages, the core functionality is in the NPM package that becomes babel-core, but Webpack integrates them together, but for each function and extension you need, you need to install a separate package (the most used is parsing ES6 Grammar of the babel-preset-es2015 package and parsing JSX of the babel-preset-react package)

Install command:npm install--save-dev babel-core babel-loader babel-preset-es2015 babel-preset-react

then write in the config entry for webpack.config.js:

{

test:/\.js$/,

Exclude:/node_modules/,

Loader: ' Babel ',//In the Webpack module section of the loaders configuration can be

query:{

presets:[' es2015 ', ' react ']

}

}

and add ES6 syntax to the work.js.

First sign out of the configuration item try

Then look at the syntax in the Webpack.js after the completion of NPM start :

As you can see, there is no conversion

Open index.html with Chrome browser, still can pop 7, because the latest Google browser support ES6 most of the syntax

And then cancel the notes in Webpack.config.js.

run the command again : NPM start

then take a look at the compiler-completed Webpack.js's syntax for this code to change

It turns out to be a familiar grammar.

Open index.html again , still pop up 7

can also be installed React, the command is NPM install--save React react-dom

Webpack Study notes Five

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.