Getting Started with webpack

Поділитися
Вставка
  • Опубліковано 13 січ 2025

КОМЕНТАРІ • 121

  • @r.s.h.1752
    @r.s.h.1752 9 років тому +35

    Wow. probably the best technical video I've ever seen! Gets straight to the point, no fluff, assumes a certain level of skill. You should do all the tech videos on the net!.

  • @blessenm
    @blessenm 8 років тому +4

    This is a really great intro. Been trying to understand a existing react codebase at my new job and i realised I couldn't go further without understanding webpack. Got a basic understanding of what loaders are doing. Need to learn more about code splitting and chunks now.
    Thanks for this video. It really helped. Keep up the good work.

  • @neoneoneoneone
    @neoneoneoneone 8 років тому +3

    Best explanation ever...I've having so much difficulty switching from a LAMP stack to Node-related stack.

  • @mxschumacher
    @mxschumacher 9 років тому +6

    Concise, good speed, practical explanation. Thanks a lot, exactly what I needed.

  • @LucasBernardodeSousa
    @LucasBernardodeSousa 7 років тому +4

    To anyone having problem with the css-loader part, please consider that you are not allowed to omit the "-loader" sufic for loaders anymore, wich requires you to use "require('css-loader!./bear.css')".

  • @GregKostelloPlus
    @GregKostelloPlus 9 років тому +1

    Great job! Super clear with explanations at each step. Thanks!
    If you've ever wondered how to get started with Webpack, this video is for you.

  • @vigneshudhay8144
    @vigneshudhay8144 7 років тому +1

    This is the best tutorial for webpack beginners, which actually gets webpack running for you. Thanks a ton.!!! :)

  • @kaivonafsari9741
    @kaivonafsari9741 9 років тому +1

    You're the best man. This is was way better than any blog post I've read.

  • @andychen5571
    @andychen5571 8 років тому +1

    This tutorial is totally what I am looking for! Thanks for this introduction! It's really helpful!

  • @nicholashill5851
    @nicholashill5851 8 років тому +1

    great video. I have been using webpack for a while and learnt form such a simple walk through of webpack at it's simplest level.

  • @christopherbilliau1308
    @christopherbilliau1308 8 років тому +2

    This was a great intro for me as I am just learning about npm and modules.

  • @deelanmj
    @deelanmj 7 років тому +2

    This helped demystify webpack for me. Thank you for this clear tutorial!

  • @ariellrodriguez939
    @ariellrodriguez939 9 років тому +2

    fun and to the point, you are a good teacher sir

  • @kalyanChatterjeeDeveloper
    @kalyanChatterjeeDeveloper 9 років тому +1

    Great tutorial. Clear and precise. Love it.

  • @noherczeg
    @noherczeg 9 років тому +16

    Just don't stop doing these :)

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому +2

      noherczeg No plans to stop. :D Thanks for watching! :)

    • @noherczeg
      @noherczeg 9 років тому

      I curious though, does the uglified code work with Webstorm's debugger as well?

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому +1

      noherczeg Yep! It should as I believe WebStorm just uses Chrome dev tools via an extension. You just need to ensure you've got your source maps in order. webpack has many options for handling source maps: webpack.github.io/docs/configuration.html#devtool

    • @noherczeg
      @noherczeg 9 років тому

      Thanks! :)

  • @tonyBeloni
    @tonyBeloni 8 років тому +1

    Great Video Kyle - clear and succinct - thanks

  • @Klaatu91
    @Klaatu91 9 років тому +2

    Great video!!! very well explainded and really easy to understand

  • @leehorngyi4333
    @leehorngyi4333 8 років тому +1

    I have a question at 5:16.. Why isn't the output for the bundle.js is needed? I didn't understand that and the how does the index.html being rendered? Sorry I am new here

    • @AlessandroMuraroIT
      @AlessandroMuraroIT 8 років тому

      Did you find out? looking for the same info :)
      I think what the webpack dev server is it injects a bundle in the page... but I'm not sure

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому +1

      Great question! webpack-dev-server will compile the bundle.js on demand or in other words, each time you request that file from the server it will compile and serve it to your browser. Which can be a little faster as it doesn't have to write it to the file system, have the server read it and then serve it from the file system.
      It's only for development though. So when you're ready to publish your site to production, you would compile to a file instead and then serve that. Hopefully that answers your question.

    • @leehorngyi4333
      @leehorngyi4333 8 років тому

      thank you so much Kyle Robinson Young Alessandro Muraro

  • @albert275
    @albert275 9 років тому +2

    This was incredibly helpful. Thanks a lot man!

  • @yolloyd
    @yolloyd 8 років тому +3

    Kyle Robinson Young, YOU'RE AWESOME!

  • @nosajghoul
    @nosajghoul 9 років тому +1

    Im sorta new to a few of these things, but I have a question :
    At about 5:01 you start showing how webpack-dev-server automatically re-bundles things. What would be the [difference, upside, downside] to doing this with gulp (assuming this can be done with gulp)?
    great vid though. Nice pace, nice clarity.

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому

      +dfdhherhehhzdhdhtrhdhdhdshehhfdh Yep! webpack has an API in which you can integrate into gulp: webpack.github.io/docs/usage-with-gulp.html or if you want a streaming interface to webpack: github.com/shama/webpack-stream
      With webpack, you don't always need a separate build tool though. If you're just using gulp to bundle/minify/compress code, webpack can do those things. Otherwise if you're doing other types of operations that webpack isn't geared for, a separate more generic build tool like gulp is useful.
      The advantage webpack has is it uses a dependency graph and can do incremental builds. Where a generic build tool doesn't and has to rebuild all the files each time.

  • @ghrARASH
    @ghrARASH 7 років тому +1

    very nice without too much fluffy stuff . i wish all dev tuts are like this one not 6 hours on pluralsight or lynda. thanks. very nice

  • @roylee3196
    @roylee3196 9 років тому +1

    just what i'm looking for, good job for putting this up :)

  • @agent4140
    @agent4140 5 років тому

    Watching this made me dance..finally get webpack, thank you!

  • @ericj.vandervelden5253
    @ericj.vandervelden5253 8 років тому

    At 12:21 you import ./base.css. Can you also in the same way import bootstrap.css from node_modules? I tried but I don't know how to do it.

    • @raviroshan2talk
      @raviroshan2talk 8 років тому

      Just do import from 'bootstrap/fileName.css'
      No need to put './bootstrap/fileName.css
      '

  • @trihuynh9825
    @trihuynh9825 8 років тому

    Thanks for your tutorial. Just a couple of questions:
    1. When you run npm init, how can you get the dependencies defined in package.json right away?
    2. In package.json, do we still need to specify ./index.js for webpack-dev-server since we already defined the entry point in webpack.config.js ?

  • @calvincrane
    @calvincrane 9 років тому

    Great tut !
    Not sure I like some of the webpack ideas from a build perspective do I really want my css made into a js module ? I still really like gulp but am here because of browserify not handling react require well.

  • @WoeEMoW
    @WoeEMoW 6 років тому +1

    couldn't get npm start to build the bundle.js unless my start script reads: "start": "webpack ./script.js -o bundle.js"

  • @nepomuk4283
    @nepomuk4283 9 років тому +2

    First off: I really like your style of explaining. You fill up knowledge-gaps and answer a lot of my spontaneously occuring questions while watching your videos. For this video I still have a question though. That Webpack-dev-server function seems to be pretty neat, but is there a way to give it a HTML file it loads the bundle in? Or do I have to create all the HTML-tags dynamically via JS at the beginning?

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому

      +Nepomuk Leutschacher Thanks! :D
      With webpack-dev-server, the index.html file is optional. If you don't supply one in the --content-base folder, it will create one for you. Otherwise if you have created an index.html file, it will use that one instead. Does that answer your question or did I misunderstand the question?

  • @kulaivanova1237
    @kulaivanova1237 7 років тому

    Thank you Kyle. One quick question. I am trying to run a webpack project on port 80. I am using "npm run server:prod". Using webpack config file, I changed port number to 80 - i.e. something like below
    const PORT = process.env.PORT || 80;
    However, whenever I run the project using npm run server:prod, it's always running on port 8080 or 8081.
    Any thoughts on what I am doing wrong here, how can I run prod on port 80

  • @d-one-and-only
    @d-one-and-only 8 років тому

    Great tutorial. Are there any major changes from this tutorial when considering the new version of webpack?
    Thanks and Regards

  • @ashadiiputu4087
    @ashadiiputu4087 8 років тому +1

    Really helpful and easy to understand

  • @slim_mike
    @slim_mike 8 років тому +1

    this is it! Thanks Kile! this is very helpful

  • @sherifkhattab1313
    @sherifkhattab1313 8 років тому +1

    Thanks a lot..
    at another comment you have written: "Just do import from 'bootstrap/fileName.css'
    No need to put './bootstrap/fileName.css"
    so why when require jquery we just do require('jquery') no ('jquery/dist/jquery.js')?

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому +1

      If you leave off the `./` in the require statement it will attempt to resolve the 3rd party module. In other words, it will look for a package in the `node_modules` folder (or wherever else you've configured webpack to look).
      Within the `node_modules/jquery` folder is a package.json that defines a `main` key. webpack will check for that when resolving the module (among other ways, such as a file named the same as the package or named index.js within the package, to try and find the appropriate file to load).
      Check out this page: webpack.github.io/docs/resolving.html

    • @sherifkhattab1313
      @sherifkhattab1313 8 років тому

      Grea Thanks again Kyle .. also someone has said that in 2016 people stopped using requireJs so what are people using with webpack nowadays?

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому

      You can use AMD syntax (which requirejs uses) with webpack. I'd say use whatever you prefer. I personally prefer commonjs syntax (Node.js style).
      A lot of people are starting to use the ES6 module syntax now too (I did a video on it ua-cam.com/video/_3oSWwapPKQ/v-deo.html). webpack can read that syntax too.

  • @mikebestfilms
    @mikebestfilms 9 років тому +1

    Exception tutorial, really helpful thanks :)

  • @santosharakere
    @santosharakere 9 років тому +1

    Excellent introduction. Thanks.

  • @marilynbarber3549
    @marilynbarber3549 9 років тому +1

    Great video, hope you follow with another one for Webpack 2

  • @leahsmartie
    @leahsmartie 9 років тому +1

    Helped me understand it a lot better. Thanks!
    P.S. Anyone else keep hearing minecraft spider noises in the background?

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому +1

      +Smartie I may or may not have been playing minecraft while recording that video. :)

  • @whereitsfrom
    @whereitsfrom 9 років тому +1

    Hey Kyle, thx you're a great explainer :), what's the best 'directory' solution with webpack, so to avoid having to require relative paths such as require('../../../../../../components/annoying') ? I'm currently working on a project using vue/laravel/elixir(gulp/browserify) thinking maybe webpack is a better solution, have you got a chance to work with webpack/vue? thnx for your time !!

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому +1

      +whereitsfrom Thanks! I haven't used Vue too much yet. But I have ran into long paths with relative requires. The ideal solution is to structure your app to avoid having to do it. The primary reason to avoid that pattern is if someone makes a change to the require()'d upper level file, it will have cascading consequences across the app. The alternative is to structure the app into smaller standalone modules that get glued together.
      Although sometimes that ideal structure isn't possible. With webpack you can utilize alias config: webpack.github.io/docs/configuration.html#resolve-alias So if you add an alias, { stuff: '/path/to/stuff/' } you can require from that as if it were a top level module: require('stuff/thing/infolder.js')
      Here are some more solutions (some only apply to Node.js) and lots of conversation about the subject: gist.github.com/branneman/8048520

    • @whereitsfrom
      @whereitsfrom 9 років тому +1

      +Kyle Robinson Young thx! 'resolve-alias' seems to be just what i was looking for.. cheers!

  • @MrSkyhui
    @MrSkyhui 8 років тому +1

    thank you very much. this video help me to much!

  • @realB12
    @realB12 8 років тому

    Absolutly great presentation. Great teacher! Aboslut Pro!!

  • @desctardesctar4098
    @desctardesctar4098 9 років тому +1

    Kyle, nice video!
    1. You said that `webpack-dev-server` doesn't need an output file. So this server is only for quick testing and when I think I am ready for production I must use `webpack -p index.js bundle.js` to compile the bundle.js and use it. Am I right?
    2. Can you make quick video with an example of how to use `webpack` with Angularjs, jQuery and twitter-bootstrap. I guess it will be really helpful for a lot of people. Thanks in advance.
    Once again - great video!

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому

      +Desctar Desctar Thank you!
      1. Yes, you are correct.
      2. Will do! I have an idea list here: github.com/shama/letswritecode/issues/1 and am planning on more webpack ones.

  • @poimarine
    @poimarine 9 років тому +1

    Nice video, really helpful :D 👍

  • @n_fan329
    @n_fan329 6 років тому

    what is the name of the CLI that are you using ?

  • @Skellingtor
    @Skellingtor 9 років тому +1

    So this really seems like a more powerful version of Browserify, is that a fair comparison ?

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому

      +Skellingtor It depends on what you're building. IMO Browserify is better for building modules. It's stricter and focused on Node.js. So your modules will likely be more compatible or more easily consumable by others. If your building an application and want flexibility to load a wide variety of modules in a wide variety of ways, webpack would be better.
      I like to say, Browserify is for modules and webpack is for apps.

  • @TheWillychester
    @TheWillychester 9 років тому

    thank you ! Great tutorial but, I have a problem because the console show me the next : Uncaught TypeError: Cannot read property 'call' of undefined. Should I ignore it? thank for you help!

    • @kylerobinsonyoung
      @kylerobinsonyoung  9 років тому

      +Andrés Pinilla Thanks! That error seems to be trying to `.call()` on a variable which isn't defined. Double check the spelling and placement of the call. It should give you a stack trace to better indicate where the error originated too.

  • @RiM0Ner
    @RiM0Ner 8 років тому

    Great introduction to webpack, thanks!

  • @rjiang21
    @rjiang21 9 років тому

    I noticed you are using require('jquery") in the js file, so I assume that the webpack is converting CommonJS into browser recognizable JS?

  • @Mark-ic4hl
    @Mark-ic4hl 8 років тому

    I am just starting to learn webpack and I have a very basic question. I've read and watched other tutorials and most of them use webpack.config.js to compile their scripts while you are using package.json instead. How are they different?

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому +1

      package.json is used primarily by npm to list the dependencies your project requires. Whereas webpack.config.js is used to configure webpack. Typically you would have both.
      webpack would be a dependency in the package.json and you might have a script that runs webpack, "scripts": { "start": "webpack" } so running npm start would tell webpack to start compiling. Then webpack would use webpack.config.js to determine which source files and output files it should build.

  • @sighmanthethird
    @sighmanthethird 8 років тому +1

    Thank you, great video! :)

  • @luanraithz2494
    @luanraithz2494 7 років тому +1

    Thanks, it's such a nice video!

  • @sasithawathmal
    @sasithawathmal 9 років тому +1

    wow simple and awesome!
    thank you!

  • @yangshuting1737
    @yangshuting1737 6 років тому

    By now, npm start of the package.json file should be : "start" : "webpack ./index.js -o bundle.js"
    lack -o

  • @tzuyuanliu3549
    @tzuyuanliu3549 7 років тому +1

    Really nice tutorial! :D

  • @kamranqadri
    @kamranqadri 8 років тому

    which terminal are you using in mac?

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому

      It's the regular Terminal app but I've modified my dotfiles a bit. They are really similar to github.com/paulirish/dotfiles though. :)

  • @susannakosic3286
    @susannakosic3286 8 років тому

    Awesome tutorial! thanks a lot :)

  • @Andrea-Giachetto
    @Andrea-Giachetto 8 років тому +1

    Good job man!

  • @mucahitinel
    @mucahitinel 8 років тому +1

    Super video, thanks

  • @eotikurac
    @eotikurac 9 років тому +1

    i've done many javascript courses but i still consider myself a beginner and i have no clue what you're doing here

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 9 років тому +2

      Start by checking out how NodeJS works. Then it will make more sense.

  • @acqzuel
    @acqzuel 7 років тому +1

    10x dude, great video

  • @changliu2394
    @changliu2394 7 років тому

    Thanks Kyle, you saved me

  • @luismuzquiz1400
    @luismuzquiz1400 7 років тому +2

    you kinda sound like the Green Hornet movie actor Seth Aaron Rogen

    • @kylerobinsonyoung
      @kylerobinsonyoung  7 років тому

      Funny enough I've heard that before, listen to the beginning of this previous video I made: ua-cam.com/video/c9j0avG5L4c/v-deo.html

  • @CariagaXIII
    @CariagaXIII 6 років тому

    things have changed in 2018

  • @ferchomarquez3464
    @ferchomarquez3464 9 років тому +1

    Great video 👍

  • @icesystem7
    @icesystem7 8 років тому

    so.. this is.. how to take a simple task like loading a script..and complicate the crap out of it. Good job Derp. If is too complicated for you to order your scrips.. maybe you have other problems to solve.

  • @Slerkan1
    @Slerkan1 9 років тому +1

    Wonderful!

  • @LarsRyeJeppesen
    @LarsRyeJeppesen 9 років тому +1

    Great video

  • @tongao3251
    @tongao3251 9 років тому +1

    谢谢谢谢,学习了。

  • @ejazkarimhunzai
    @ejazkarimhunzai 8 років тому +1

    Awesome.

  • @kevgi
    @kevgi 8 років тому

    really awesome!

  • @76ers
    @76ers 8 років тому

    5:05 - You removed "bundle.js" from the package.json so you only have index.js. So why is "bundle.js" still being referenced in your HTML when you now have "index.js"?? Is the webpack-server compiling "index.js" and renaming it "bundle.js"?? If so, then please explicitly mention this fact rather than assuming we already know.
    Also, is the name of the compiled file always going to be called "bundle.js"?? AGAIN, please mention these little details instead of assuming we already know.
    6:43 - Why does your DIV looks like ""??
    8:54 - appendChild(bear[0]) - What the heck does "bear" represent here??? Is it the file name? Is it an Array? Can we name it something different?? Again, can you please break down your tutorials and explain these little bits instead of just flying through the code? Not all of us are JS experts and we're trying to learn.
    9:20 - 1.bundle.js - You only have "bundle.js" in your HTML so where the heck is the file "1.bundle.js" being pulled from?? Is it a temporary file that's stored in memory?? And how is it being injected into the page?? AGAIN, PLEASE MENTION ALL THESE DETAILS instead of just flying through stuff!!
    (throws hands up)
    That's it... I give up. :(

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому

      +76ers It sounds like my style of teaching might not be a good fit for you. I think people learn more effectively when allowed to explore and discover details on their own. So they are purposely short and aimed to introduce to common topics of a subject. There are a lot of videos on youtube that go long deep diving into details and at least for me, I tend to zone out after about 20 mins. I understand my videos might not be for everyone.

    • @lukaschen6799
      @lukaschen6799 8 років тому

      1: "" means a empty div: ""
      2: the variable 'bear' have the jQuery object wrap around it, so you cannot do vanilla appendChild. You get the vanilla DOM by referencing the 1st item in the array: 'bear[0]'

  • @optyler
    @optyler 8 років тому

    what a beautifullll green :)

  • @vlady100k
    @vlady100k 9 років тому

    Dude... please forget the bears... everyone watching this can understand without a fkin bear

  • @SuperNirupam
    @SuperNirupam 8 років тому

    I think the tutorial can be much more simplified for beginners

    • @kylerobinsonyoung
      @kylerobinsonyoung  8 років тому

      ok

    • @mrdeurknopp
      @mrdeurknopp 7 років тому

      Don't worry about this guy, the tutorial is nice and succinct. Webpack isn't exactly something absolute beginners should be messing around with anyway :)

  • @aguilajackson
    @aguilajackson 8 років тому

    Thanks a lot! Very helpful!