Sobecauseitis 10 videos, I diddecidetospreadthingsoutinsteadofjustrushingthrougheverything.
So I willnottakeoffenseifyouspeedthroughanyvideosorskipthem.
That's whattheycouldhavereposeforus.
Well, if I weretakingthiscourse, I'd probablyjuststartbylookingatthecode.
I'vealwayslikedtodothatbefore I watchanyvideos.
Okay, solet's getgoing.
Let's talkaboutwhatwentbackisthisistheWebPeckhomepage, and I likehowthisimageexplainsitwentPackcanbeveryconfusingandintimidatingandcausemanyheadacheswhenyou'reactuallysettingitupandconfiguringit.
Ittakes a bunchofdifferentassets, differentfilesofdifferenttypes, jobscriptimageslike S V, G, P and G J pegs, CSSstylesheetsorless, orsasallsortsofdifferentfiles, anditcombinesthemdown.
Soifyouwrite a filethatdependsonthreeotherfiles, thosethreeneedtobeincludedfirstsooftenit's a verycomplexwebofdependenciesandlargerAPS, anditwouldbeverydifficulttomanageitonyourown.
Webpackdoesitforyou, anditspitsoutoneortwoorhowevermanyfilesyoutellittobundle, and I likehowtheygethaveRepoexplainsit.
WhatBeckis a bundlerforJavascriptandfriendspacksmanymodulesinto a fewbundledassetsandthroughsomethingcalledloaders, whichwilltalkaboutmodules.
Couldbecommon.
JsEssexCSSimagesJasonCoffeeScriptBabaBabaBlockThelistgoeson, sowe'regonnaseehowtodo a lotofthisstuff.
Butfirst I wanttoshowyouanexampleofanappthatit's alreadybuiltwillbecreatingourownfromscratchandconfiguringWebPeck.
It's a a colorpickerswebsite, sothere's a bunchofcolorpictures.
Clickononeyouknowyoucancopy a color.
There's a wholebunchoffeaturesthingslikechangingfromhextoRGBtoour G P A.
Allofthatinvolves a librarythathelpsfigureoutcolorsandandconvertbetweendifferentcolortypes.
I'm using a librarytogettheseniceslidersandthislittlesnackbarthingthatpopsupdownthere.
There's transitions.
I'm usingthereactrouter.
Mypointis, there's a lotofdifferentstuffgoingonthatisthirdpartycodethat I'm dependingon.
There's somecodetohelpwithDragondropThere's codefor a colorpickerso I cancreatenewpallets, reorderthem, I saveit.
Andthere's code, inadditionforthisemojipickerhereso I canselectanemoji.
Anyway, that's enoughwiththeAPPitself.
Butit's sufficientlycomplicatedwhere I thinkitmakessenseas a goodexampleforWebPeck.
Soifwetake a lookatthecode, thereare, I don't know, 20 somethingJavaScriptcomponentsorreactcomponentsthat I'vewritten, plus 20 somethingCSSfiles, plus a wholebunchofdependencies, lotsofmodules, thingsthat I'm using, likereactcolor.
I'm usingthisemojimartamusing.
Ah, material.
You.
I react, ofcourse.
Someformvalidatorlibraries.
There's a lotofdependencies, andthisisfor a singlefile, andthere's 20 somethingofthem.
Basically, eachoneoftheseissinglefilethat I wrote a massivestring, andit's beingwrappedin a Webpackmoduleandthisiskeepingtrackofwhatitexportsandwhatitdependson, andyoucanactuallysee.
Forexample, thisismanypalatedotJs.
Okay, that's oneofthecomponents.
Andif I keepscrollingover, youcanseethingslikethis.
There's now a builddirectoryandinsideofthatbuild, ifwelookatourJavaScript, there's a coupleoffiles.
There's the's sourcemapswecanignore, butthey'reallmen, if I'd know.
Thisisthesamestuff I waslookingatearlierwhen I wasusingtheDevversion, butnowit's beenallcrammedtogetherandmodified, and I haveseparateCSSfiles, butifwelookatthem, they'reallofmyCSS.
It's a hugeheadacheonlargegapstotryanddosomethingwithoutWebpackorsomethingcomfortable.
Allright, so I mentionedthisintheintrovideo, but I wanttobringitbackupincaseyoumissedit, oryouskippedrighttothisvideosoyoucouldstartinstallingstuff, which I get, bytheway, uh, but I wanttobringitupbecausethisrepoisveryimportantfortherestofthiscourt's nextnineorsovideos.
Itincludesallofthecodeandallofthecommitsthat I makeinallofthosevideos.
Sothelinkisinthedescription.
Itincludesdetailed, commitmessages.
I'lltalkaboutineachvideo, whichcommit I'm currentlyon, so I dotypeeverythingfromscratch.
Itistruecodealong, butifyouwanttoreferencethechanges I'm makingorifyougetlost, oryoujustwannalookatitwithoutthevideo, clickon a commitandyoucanseethediff.
But I wantedtomakesomethingsimpleenoughtofollowalongwithOkay, sothefirstthing I'm gonnadoisbreakmycoatupintoseparatefiles, sothatwilltakeusintocommitto.
Sothere's a couplethingsthat I couldbreakupfrommyappJsFirstofall, wehavethesedifferentfunctions.
I'm gonnaputthoseintheirownfileeachoneanditsownfilein a utilitiesoryoutillsdirectorybecausewemightwanttousethosesomewhereelseintheappitcheckingifinputsarevalid, checkingorparsinginputs.
That's functionality.
Wecouldusesomewhereelsealso, youknow, we'rejustbreakingitupsothatwehavesomethingtobundleitsnotveryfuntobundle a singlefile.
Ah, I'm gonnamakeactually, I'm gonnarefactorourcodetohavetoserviceisanalertserviceand a componentservice.
Andthen I'm gonnahave a functioncalledrunthatactuallystartsallofourcode.
So I'm gonnadothatnow I'm goingtomake a newfolderinsideofsourcecalledAPP.
Andthen I'm gonnadothesamethingforoursecondutilityfunction, whichiscalledinputsDash R DashvaliddotJsand I'm gonnacutthisoutandpasteitinrighthere.
Therewego.
And I'llfastforwardthroughsomeofthesechanges.
But I'm gonnamake a couplemorefilesjustsoyoucanseethefilenamesintheappgonnahavealertdotservicedotJs I'm goingtohave a componentdotservicedotJsAndthen I'm actuallygonnamovemyappJsintoapp.
So I'm gonnadeletethiswhen I'm done.
Okay, so I'm gonnafilloutthesefilesagain.
It's thesecondcommitifyouwanttoseehow I brokethecodeupforyourself.
Okay, so I'm back.
ThisisthealertserviceclasscalledalertService.
I justmoved a lotofthecodeintothis.
Itreliesoninputsarevalid, Forexample, wealsohavecomponentservice, whichdoesn't haveanydependencies s sofar.
Andtheninsideofap, Jstherial, thenewFDA s.
I'm gonnadeletetheoldonethat's outsideofmyfolder.
Now.
It's justallinthisappfolder.
So I havemyutilitiestofunctionsandthen I havealertservicecomponentserviceandthenapJsisgoingto.
Inputsarevalidpartsinputsandsoon, andwe'regoingtocallsomecodefromthisfileSowhen I bundlethisfilewithNPMstart, it's gonnagograballtherelevantdependenciesandputthemallinto a filewhich, ideally, isgonnaputallofthesefivefilestogetherforus.
Sonow, insteadofmyindexdress, I canimportrunfromandthenthepathtothatfilefromIndextrey s isdotslashhopenotintherightspotdotslashappslashappisthenameofthefile.
Okay, so I mentionedyoumaynotwanttoactuallyrunthisifyoudon't havethissetupasdissedandmainJsbecauseit's gonnamakeyou a newfolderand a newfileand I'm justgonnadeleteminerightafter.
Butletmeshowyouthatitworks.
Fingerscrossedthatitdoeswork.
Let's seewhathappens.
Allright, wehave a newfolderandfilecalledhellodotJs.
Well, we'regoingtospend a lotoftimeaddingindifferentpluginsandloadersandhavingwhatPeckhandledifferenttypesoffiles.
Butfornow, rememberhow I saidAllofthisismodifiedanduglyandhardtounderstand.
What's happeningisthatit's runninginproductionmodebydefault, and I cantellit, Let's notdoproductionbutsetmodetobedevelopment, andthatmodeisgoingtotellittostopmenif I Sonow, if I rerunmycodeorif I rerunWebpackinsteadofdissed, wehave a mainJs, andit's nolongerallscrunchedupintothisreallyhardtoreadthingofcoatnow.
Usuallyyou'renotgonnareadthisanyway.
That's notthepoint.
You'vereadyourcodeinthefileswhereyou'rewritingit, butthenWebpecsspitsout a bundle.