React (Babel) and Sass webpack Tutorial: Extract CSS Into Its Own Separate File

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ส.ค. 2024
  • Join my premium 2024 bootcamp here learnwebcode.teachable.com/p/...
    Let's learn how to setup Babel, React, JSX, CSS, Sass and more with webpack!
    0:00 Intro
    1:27 Getting Started
    6:19 Loaders in webpack
    15:26 CSS
    22:55 Sass
    26:55 React Math Game
    31:11 Separate Component Files
    33:41 Optimizing For Production
    37:44 Extract CSS Into Its Own File
    42:49 Hash / Cache-Busting String
    52:04 @babel/preset-env
    57:01 Emmet in JSX in VSCode
    59:59 Outro
    Starter Files GitHub: github.com/LearnWebCode/youtu...
    CodePen Copy & Paste Reference: codepen.io/learnwebcode/pen/E...
    Finished Product GitHub: github.com/LearnWebCode/react...
    Playlist for this full series: • Brad's Bootcamp - Free...
    Follow me for updates on new episodes:
    Instagram: / javaschiff
    Twitter: / learnwebcode
    Facebook: / brad-schiff-1542576316...
    Twitch: / learnwebcode

ความคิดเห็น • 93

  • @saikiransk497
    @saikiransk497 3 ปีที่แล้ว +5

    Thanks for the awesome tutorial Brad. Great work.
    I wanted to add 2 points here, from webpack 5 we don't need clean-webpack-plugin. Adding clean: true to the output config will be enough and webpack manifest plugin should be a named import.
    const { WebpackManifestPlugin } = require('webpack-manifest-plugin');

  • @adiemar3974
    @adiemar3974 2 ปีที่แล้ว +1

    im pretty exited about this one and just finished his previous course.

  • @genesesrevelation89
    @genesesrevelation89 3 ปีที่แล้ว +2

    The best tutorial in ReactJS for starters.

  • @nitesh7546
    @nitesh7546 2 ปีที่แล้ว

    The best webpack tutorial out there..

  • @foupax
    @foupax 3 ปีที่แล้ว +2

    Every TH-cam Dev Student who makes it to this new series will make a great leap to his achievements! 👍💖

  • @tusharghildiyal6814
    @tusharghildiyal6814 3 ปีที่แล้ว

    you are the best web development teacher on the internet. period !!

  • @filipm5509
    @filipm5509 3 ปีที่แล้ว +2

    I watch all and every ad on your videos. I want you to know that.

  • @christopherpink842
    @christopherpink842 2 ปีที่แล้ว

    THANK YOU VERY MUCH!!!!!!!!! I wanted to learn how to use react without create-react-app

  • @techbd2477
    @techbd2477 3 ปีที่แล้ว

    Thanks Brad, all the time when I play your video I pushed the video on 5 or 6 second and play it's again to enjoy your "Brand Of Ambassador" 😊

  • @KayoleKnight
    @KayoleKnight 3 ปีที่แล้ว +2

    i found this when i really needed this combination...thank you so much bro..i subscribed

  • @danielangulo1900
    @danielangulo1900 3 ปีที่แล้ว +1

    Great lesson and was able to deploy to netlify. Thank you ;)

  • @sudharsanthiyagarajan2596
    @sudharsanthiyagarajan2596 3 ปีที่แล้ว

    Your channel is an hidden gem🥰

  • @shahriarparvezshuvo4760
    @shahriarparvezshuvo4760 3 ปีที่แล้ว

    It's a Fresh Morning Learning materials for me. Good to see you both. 😍😍😍

  • @playstore-so2xm
    @playstore-so2xm 3 ปีที่แล้ว

    You are the best!! Keep on coming with these amazing things👍👍!! Thanks a lot!!😊😊

  • @MaxTheFireCat
    @MaxTheFireCat 3 ปีที่แล้ว +1

    i almost fainted when you said this was the last video but then you said on this chapter so I'm all good

  • @omphaluskua3249
    @omphaluskua3249 2 ปีที่แล้ว

    Very very nice and neat, clean and clear. CHEERS!

  • @shivamkumarjha3302
    @shivamkumarjha3302 3 ปีที่แล้ว

    Born to teach. As always excellent explanation.

  • @bertugmete2855
    @bertugmete2855 2 ปีที่แล้ว

    It was great ! Thank you so much Brad. A video on performance optimization would be nice :)

  • @sanata2003
    @sanata2003 3 ปีที่แล้ว +3

    I downloaded the code from github and when I tried to npm install sass sass-loader an error appeared, because fsevents it is not supported on Linux. I searched the solution and after deleting the package-lock.json I could run npm install again and then the problem was solved. Cool!

  • @jianxie2402
    @jianxie2402 3 ปีที่แล้ว

    I really enjoyed your video. Thanks a lot!

  • @nguyendat4275
    @nguyendat4275 3 ปีที่แล้ว

    best teacher ever seen!

  • @CodingAfterThirty
    @CodingAfterThirty 3 ปีที่แล้ว +5

    Hey, just want to say thank you for what you do. BTW, I took tour React course it was great.
    Now going over your JavaScript course where you combine JavaScript development front and backend together.
    Loving every part of it.
    From all instructors, you are still the best at making videos that help beginners get started with learning web dev.

  • @_rachid
    @_rachid 3 ปีที่แล้ว

    Thank you .. You demystified webpack for me !

  • @bhavleensingh6929
    @bhavleensingh6929 3 ปีที่แล้ว +1

    brad bhai h apna.

  • @akactivekarishmagroupbhila5380
    @akactivekarishmagroupbhila5380 3 ปีที่แล้ว

    I saw your wordpress related course in udemy its really owsm...thanks because of you wordpress development is very easy for me.

  • @uykerrykaberga
    @uykerrykaberga 2 ปีที่แล้ว

    thanks, really helped

  • @wshraim
    @wshraim 3 ปีที่แล้ว

    brad you're amazing

  • @hotvineofficial7242
    @hotvineofficial7242 3 ปีที่แล้ว

    This lesson is best that i watched ))

  • @chaosevolved9334
    @chaosevolved9334 ปีที่แล้ว

    man u are so awesome u explain stuff like a king thx so much bro i wish that u make a course on mongoDB

  • @shnam928
    @shnam928 2 ปีที่แล้ว +2

    The best tutorial! It'd be great if you could add express to this project, so that we could see the folder structure, connection of front end and backend and also the functionality of webpack in a fullstack project.

    • @LearnWebCode
      @LearnWebCode  2 ปีที่แล้ว +2

      That is a great idea for a video! Just added it to my notes / video topic list.

  • @jordanlewis3530
    @jordanlewis3530 3 ปีที่แล้ว +1

    Heads up to anyone watching this after me - if you haven't needed to already, you will need to install webpack@5.0.0 in order for SASS to work.

  • @CristianeDamacena
    @CristianeDamacena 3 ปีที่แล้ว

    Amazing! Thank you!

  • @viraj_singh
    @viraj_singh 3 ปีที่แล้ว

    I would have paid for this course happily.

  • @chlopgotuje
    @chlopgotuje 3 ปีที่แล้ว

    Brad nice to see Y again

  • @arfan8544
    @arfan8544 3 ปีที่แล้ว

    Thank you very much.

  • @msvmanikantasrivishnu7788
    @msvmanikantasrivishnu7788 3 ปีที่แล้ว

    Thank you

  • @beckyb9215
    @beckyb9215 3 ปีที่แล้ว

    I also love SASS :)

  • @elmlisa2124
    @elmlisa2124 3 ปีที่แล้ว

    love it ,

  • @weizhang2389
    @weizhang2389 3 ปีที่แล้ว +4

    First! Love this tutorial series!

  • @rangabharath4253
    @rangabharath4253 3 ปีที่แล้ว

    awesome

  • @lirenguo7650
    @lirenguo7650 3 ปีที่แล้ว +2

    Hello Brad, I bought and finished your React for the Rest of Us course on Udemy and loved it! I'd like to continue learning more in-depth about React to create web applications. Are there any resources/course you can point me to? Thanks a lot!

  • @ahmedboutaraa8771
    @ahmedboutaraa8771 3 ปีที่แล้ว +1

    I am enjoying the bootcamp as much as your pussycat is enjoying the plant

  • @streamx2
    @streamx2 3 ปีที่แล้ว +4

    I was first and Brad can confirm this. I just got excited and forgot to comment. Haha fighting over who was first

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +2

      Haha, it's true. You were so early it was a comment on another video about this video.

    • @streamx2
      @streamx2 3 ปีที่แล้ว

      @@LearnWebCode can you please do a saperate video on mongoose. I know you will cover databases soon do maybe you could cover it then. Everytime i watch a video on it it confuses me. Mongo inself is easy

  • @TheCodebookInc
    @TheCodebookInc 3 ปีที่แล้ว +1

    Needed something for the vue.js too, with lazy loading, facing issues with my project especially with router. It would be nice to add that too

  • @mohamedawde9508
    @mohamedawde9508 3 ปีที่แล้ว

    Thumb up!

  • @MaxTheFireCat
    @MaxTheFireCat 3 ปีที่แล้ว +2

    where are you brad? I'm really waiting forward for the next episodes.

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว

      I'm back 🙂 There will be a new video in the morning (Pacific).

  • @donyu421
    @donyu421 3 ปีที่แล้ว

    I'm a big fan of your teaching since WP. Thank you for another valuable lesson.

  • @regilearn2138
    @regilearn2138 3 ปีที่แล้ว

    Hi really great video,and If you can please let me know,how to add material ui and styled component(both together is must) to this setup, appreciate your help

  • @BenDover-ii4hz
    @BenDover-ii4hz 3 ปีที่แล้ว +1

    Really liked this tutorial Brad, thank you!
    A related question... suppose we're using a CSS "framework" such as Tailwind/Bootstrap/etc, along with our custom SCSS, when the main css is compiled, will it only pull the css used in our app or will it pull everything (asking for optimization purpose). If possible, can you do a short tutorial on this and how to optimally implement svg/ico/icons along with pictures (formats/sizes & "lazy loading?"), minifying css/js files, and etc? Would really like to learn some optimization tricks for creating best-practices habits.
    Thanks again for these well explained tutorials.

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +2

      Glad it was helpful, and thanks for the feedback! Check out the "purify-css" package on GitHub / NPM for filtering out unused CSS. I'll add SVG and responsive images to the list of possible extra credit videos.

    • @BenDover-ii4hz
      @BenDover-ii4hz 3 ปีที่แล้ว +1

      @@LearnWebCode Awesome! Will tinker with purify-css pkg.
      One last thing, in one of those possible extra credit videos, if you have time, please add a tutorial on randomizing CSS Class names when publishing on production env (similar to how NYT's does it - made it difficult to webscrape the site for an old learning-project. Would be cool to learn how that's done).
      Thank you for a quick reply. Cheers

  • @DRocksRecords
    @DRocksRecords 3 ปีที่แล้ว +1

    Its nice that you go full custom webpack. Thanks for the tutorial. Do you recommend Create React App or prefer to avoid it?

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +7

      Create-React-App is great, but it's not usually used in most of the real world projects I've been on. Usually a project will have some sort of workflow / automation needs outside of just React, or you'll want to integrate with another system (Laravel, WordPress, any CMS / framework etc...) so you might as well be able to implement React yourself. It's just a package like any other from npm, it just needs the JSX transpiling. Just my opinion, not trying to pretend it's a fact, I just don't like how "Create React App" hides everything away from the end-user which can make things feel "mysterious" or "magical" and then you're not sure how to use React without it.

    • @DRocksRecords
      @DRocksRecords 3 ปีที่แล้ว

      @@LearnWebCode Thanks for the answer. I understand and it makes sense to me also. For example when I needed to add imageOptimization to my workflow I had the choice to either eject from the CRA template or use Gulp. I ended up using gulp cause it was simpler than trying to handle all their logic. Right now I'm trying Snowpack with the React and webpack templates...

    • @dobooro
      @dobooro 3 ปีที่แล้ว

      @@LearnWebCode I've been curious about this. Thanks for sharing!

  • @binukumar6270
    @binukumar6270 3 ปีที่แล้ว

    ❤️❤️❤️

  • @tanjirmahabub5105
    @tanjirmahabub5105 3 ปีที่แล้ว

    Hi Brad, Please make a crash course video on next.js

  • @vjcpa
    @vjcpa 3 ปีที่แล้ว

    Brad, thanks for the video. I have a couple questions about autoprefixing for the css file generated and js importing tree shaking. It seems all the million plugins you installed don't do it. Anyway to see (maybe an addon video) how it can be achieved?

  • @emmanouil1453
    @emmanouil1453 3 ปีที่แล้ว +1

    Hi Brad. Are you planning any course in Udemy, on how to use React to develop Android or iOS applications?

  • @sanata2003
    @sanata2003 3 ปีที่แล้ว

    In order to run webpack-manifest-plugin I wrote in the webpack-config.js const {WebpackManifestPlugin} = require("webpack-manifest-plugin") and works now. Also, the manifest.json file only have the main.css : automainxxxxxx.css and main.js: automyBundle.xxxxxz.js references. No reference to the index.html file.

  • @73dines
    @73dines 3 ปีที่แล้ว +1

    webpack-manifest-plugin
    Author message:
    no longer actively maintained

  • @romimaximus
    @romimaximus 2 ปีที่แล้ว

    Great awesome tutorial !! ... and well i have a question ?
    let´s say instead just index.html, i would have 4 more "html" pages , and each one "onload", calls a diferent script ?
    how would i tell webpack to get these pages into the bundle,
    and in "production mode", how would i call these scripts ?
    cause now they are all in one whole "bundle" right ?.... instead of diferent scripts like before "build" ?
    and that's making my brain go crazy !! lol..

  • @SajidAliSoftwareEngineer
    @SajidAliSoftwareEngineer 3 ปีที่แล้ว

    one simple thing I to want to know please.
    what short key or app you are using for crosshair cursor
    video time: 6:10 or 6:26 or at 7:38

  • @emmanouil1453
    @emmanouil1453 3 ปีที่แล้ว

    Thanks a lot Brad. I wonder why the myBundle.js is so big(~128kb) after npm run build, for just an Hello React component? Are the react and react-dom libaries we import, that make this size?

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +2

      Good question, and yes, that's one of the biggest criticisms of React; that it's a big download for visitors. I think it's worth it for web apps / really interactive experiences, but for super simple websites you can make a compelling argument to skip React in favor of a lightweight alternative. For example, "Preact" claims to only be 3kb, but I personally haven't tried it. For better or worse, React is very in-demand in terms of job descriptions which is why I favor it.

    • @emmanouil1453
      @emmanouil1453 3 ปีที่แล้ว

      @@LearnWebCode Thanls for the info Brad.

  • @alekm4185
    @alekm4185 2 ปีที่แล้ว

    Hey Brad, how does this work with WordPress?

  • @tea42
    @tea42 2 ปีที่แล้ว

    The last part(corejs and regenerator) is bit complicated. I understand async/await is not able to be converted without core-js and regenerator plugins. But why he wrapped both settings in an array and set the parameter like useBuiltins: 'usage', corejs: 3, targets: 'defaults', he does not explain these in detail. I want to know how he came up with this solution. Is it documented somewhere? Then I googled, some similar solutions came up. I just swallowed it blindly and decided to think that's the way it goes for now.

  • @DailyIntern
    @DailyIntern 3 ปีที่แล้ว

    May i please have one desktop at the back?

  • @JimKernix
    @JimKernix 2 ปีที่แล้ว

    I just tried this again and when I pasted localhose:8080 in the address bar it wouldn't load and I got the following error in the console: crbug/1173575, non-JS module files deprecated.
    Anyone else get that?

  • @neelabhdutta6691
    @neelabhdutta6691 3 ปีที่แล้ว

    It was a great start for me, but I faced a issue, it doesnt work with React Suspense, lazy.. could you help me with the changes required in config to make it work

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +1

      Hi, when installing 'react' and 'react-dom' from NPM did you include the @experimental version like this 'npm install react@experimental react-dom@experimental' ? Or does it still not work? I didn't test any of the upcoming concurrent features yet, but will once they're in the "official" version of React.

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +2

      Hi, I just tested this project code with Suspense and lazy and it worked perfectly. However, "Suspense for data fetching" instead of lazy loading components isn't officially in React yet. I used this to import a component in a lazy fashion in my main component:
      const Hey = React.lazy(() => import("./components/Hey"))
      Then down in my JSX for the main component:
      setLoadLazyComponent(true)}>Load the lazy loaded component
      {loadLazyComponent && (

      )}
      I also had this piece of state up near the top of my main component, just so the lazy loading didn't actually happen until you click the button as a test:
      const [loadLazyComponent, setLoadLazyComponent] = useState(false)

  • @RohitSharma-ey3cz
    @RohitSharma-ey3cz 3 ปีที่แล้ว

    Hi Brad, I have completed wordpress course on udemy..... Will you make laravel tutorials series? It's always tough for me to understand laravel concepts. Everybody knows if you explain the things, it will be lot easier... I am waiting for laravel course... Please...please....please

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +2

      If I cover Laravel it would need to be a basic introduction to just the essentials. The framework has so many pieces to it... I feel like a comprehensive course would need to be 70 hours long 😂

    • @RohitSharma-ey3cz
      @RohitSharma-ey3cz 3 ปีที่แล้ว

      @@LearnWebCode I know you have to devote a lot of time for it, but believe me it will really help many students like me... I hope you will.

  • @TheRealJuggaloJoel
    @TheRealJuggaloJoel 2 ปีที่แล้ว

    npm ERR! Missing script: "dev"
    ...
    anytime I run 'npm run dev'. nothing happens

  • @monirulislam8267
    @monirulislam8267 3 ปีที่แล้ว

    Hi Brad
    Thanks for the great tuts...
    By the way the following code is not working...
    presets: [["@babel/preset-env", { "useBuiltIns": "usage", "corejs": 3, "targets": "defaults" }], "@babel/preset-react"] with webpack5.
    Also devtool: "eval-cheap-source-map" is not working with webpack 5.10.0

    • @jagadeeshkumar2091
      @jagadeeshkumar2091 3 ปีที่แล้ว

      It's the same case for me too, I'm avoiding those parts for now.

  • @akhazamalolifeinsweden1603
    @akhazamalolifeinsweden1603 3 ปีที่แล้ว

    Hi, I added devtool: "eval-cheap-source-map", in webpack.config.js but it still keeps warning DevTools failed to load SourceMap: Could not load content for..... is there anybody running the same issue?

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว

      Did you stop and restart the task in the command-line? You can also try some of these other values, which might be slower, but maybe not by much, and will resolve the warning message: webpack.js.org/configuration/devtool/

    • @akhazamalolifeinsweden1603
      @akhazamalolifeinsweden1603 3 ปีที่แล้ว

      @@LearnWebCode Hi Brad,
      Yes, I did stop and restart it. I also got the same issue from React for the rest of us course as well.

  • @lovelife-xm2xj
    @lovelife-xm2xj 2 ปีที่แล้ว

    Pls upload new videos...reg, decoding web sites scripts

  • @luffyd2780
    @luffyd2780 3 ปีที่แล้ว

    react-scripts or webpack !?

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว +2

      Create-React-App is great, but I don't like recommending it to beginners because it makes React seem magical or mysterious. I think Create-React-App is one of the biggest reasons you see so many people confused on how they'd use React with their Backend / CMS of choice. I think with a more hands-on approach of configuring webpack it's clear what needs to happen and how you could use the resulting file anywhere you need to etc...

  • @marble_wraith
    @marble_wraith 3 ปีที่แล้ว

    Webpack's a joke, ridiculously over complex. +90% of the time people will only need something simple like rollup or even just native npm scripts. Other than that pretty good video.

    • @LearnWebCode
      @LearnWebCode  3 ปีที่แล้ว

      Parcel is another great simple option. I'll have to try Rollup.