Cov txheej txheem:

Puas yog siv Webpack?
Puas yog siv Webpack?

Video: Puas yog siv Webpack?

Video: Puas yog siv Webpack?
Video: siv yis ntuj neeb puas yog SAUB HMOOB thiab..?! 2024, Kaum ib hlis
Anonim

Teb tsis "xav tau" babel los yog webpack tab sis lub tsev qiv ntawv yog tsim los ntawm lub tswvyim ntawm siv ES6 javascript syntax thiab JSX (qhov tseem ceeb HTML hauv JS). Webpack yog cais los ntawm Teb tab sis feem ntau siv nyob rau hauv Teb tej yaam num rau yog vim li cas MattYao hais.

Ib yam li ntawd, puas tsim react app siv Webpack?

Siv Create React App Tsim React App siv Webpack thiab Babel hauv qab lub hood, tab sis nws tsuas yog tsim cov ntaub ntawv koj xav tau los ua haujlwm ntawm koj Teb qhov project. Yog koj tau tsim Teb apps ua ntej, koj yuav tsis tau nkag mus rau configuration ntaub ntawv rau Webpack , Babel, ESLint, thiab lwm yam. Ua li ntawd, koj tsom mus rau kev tsim koj tus kheej xwb app.

Ib yam li ntawd, kuv yuav ua li cas thiaj li khiav lub Webpack teb? Kauj ruam 2: Teeb Babel thiab Webpack

  1. Qhib cov lus hais kom sai, thiab taw qhia (cd) mus rau es6-tutorial-react directory.
  2. Ntaus cov lus txib hauv qab no los tsim cov ntaub ntawv package.json: npm init.
  3. Ntaus cov lus txib nram qab no rau nruab cov react thiab react-dom modules: npm nruab react react-dom --save-dev.

Ib sab saum toj no, vim li cas peb thiaj siv Webpack nyob rau hauv react?

Nws tuaj yeem tswj tsis tau tsuas yog ua ke thiab txo qis ntawm JavaScript thiab CSS cov ntaub ntawv, tab sis kuj muaj lwm yam khoom muaj nqis xws li cov ntaub ntawv duab (spriting) los ntawm cov siv ntawm plugins. Webpack tuaj yeem yog siv Raws li lwm txoj hauv kev rau Cassette lossis ASP. NET Kev sib xyaw ua ke thiab Minification.

Kuv yuav ntxiv Webpack rau ReactJS li cas?

Txhim kho ReactJS siv webpack thiab babel

  1. Kauj ruam 1 - Tsim lub hauv paus nplaub tshev.
  2. Kauj ruam 2 - nruab React thiab react dom.
  3. Kauj ruam 3 - Nruab webpack.
  4. Kauj ruam 4 - Nruab babel.
  5. Kauj ruam 5 - Tsim cov ntaub ntawv.
  6. Kauj ruam 6 - Teeb Compiler, Server thiab Loaders.
  7. Kauj Ruam 7 - Index.
  8. Kauj ruam 8 - App.

Pom zoo: