Learn Webpack Pt. 7: Splitting Dev & Production

Поділитися
Вставка

КОМЕНТАРІ • 64

  • @PhilipMcGuirk
    @PhilipMcGuirk 4 роки тому +73

    Getting a 'TypeError: merge is not a function' error? Fix it by changing const merge = require("webpack-merge"); to const { merge } = require('webpack-merge'); Now it should work.

    • @truejohnsolo
      @truejohnsolo 4 роки тому +1

      Clutch money comment here

    • @KiqueFM
      @KiqueFM 4 роки тому +5

      May the love of all saints bless you eternally lololo #savedMe

    • @HavePort
      @HavePort 4 роки тому +1

      omg you saved me life big time! How does this change make sense? I mean, why does that fix it?

    • @harshvardhansingh7863
      @harshvardhansingh7863 4 роки тому +2

      @@HavePort merge function from webpack-merge is not a default export therefore we have to use { merge } for named export.

    • @emmanuelfabiani8435
      @emmanuelfabiani8435 4 роки тому +2

      Yes, it is a version issue as it is working without the curly brackets in Webpack v^4.2.2 but not in v^5.1.1 : try putting merge between curly braces like this:
      const {merge} = require("webpack-merge");

  • @jinwookkim8511
    @jinwookkim8511 5 років тому +47

    best webpack course ever! :)

  • @rohanasif
    @rohanasif 2 роки тому

    The series is awesome... and some of the comments here addressing major issues after newer webpack versions really make me happy to read!... People here are awesome!

  • @wanarchives
    @wanarchives 2 роки тому +12

    UPDATE: For webpack 5.0.5 and up must use
    const { merge } = require('webpack-merge');
    to avoid error merge is not a function

  • @mouazsabagh6140
    @mouazsabagh6140 5 років тому +5

    the best webpack course in youtube, thanks a lot.

  • @DecentralEyes
    @DecentralEyes 2 роки тому +1

    Wow, this is brilliant stuff !

  • @PhilipMcGuirk
    @PhilipMcGuirk 4 роки тому +25

    If you're running webpack5, you may need to change (in your package.json) 'webpack-dev-server --config webpack.dev.js --open' to 'webpack serve --config webpack.dev.js' Hope that helps someone.

    • @meghalbisht6768
      @meghalbisht6768 4 роки тому +2

      thanks, it helped! :)

    • @knyto2
      @knyto2 4 роки тому

      This really helped! Thanks for this. What about the --open option? What is the equivalent?

    • @knyto2
      @knyto2 4 роки тому +1

      Nvm, I see in the webpack docs
      webpack serve --open 'Google Chrome'
      The browser application name is platform dependent. Don't hard code it in reusable modules. For example, 'Chrome' is 'Google Chrome' on macOS, 'google-chrome' on Linux and 'chrome' on Windows.

    • @miketermeijer2120
      @miketermeijer2120 4 роки тому +1

      Are you a F&^%$ Hero or What!!!! THANKS

    • @fredericozanoni3749
      @fredericozanoni3749 4 роки тому

      Thx !

  • @Mia_Quit-9yrold
    @Mia_Quit-9yrold 3 роки тому +2

    this series is totally amazing! thanks ever so much!

  • @devinegger4570
    @devinegger4570 Рік тому

    Hey Colt, just wanting to say thanks for putting together this course it's seriously awesome! One thing I can't seem to wrap my head around is when to use --save or --save-dev on npm install... from all the documentation it seems like --save-dev is only for dev dependencies, and so ok that makes sense. But then there are occasions where you're installing something that you say is specifically for the production build and --save is not used, but --save-dev. If you (or anyone else in the comments) could help shed some light on this with me that would be so great!! TY in advance!

  • @userbilas
    @userbilas 4 роки тому

    Wow dude, clear and useful. Interesting that way when you separate config files... love it!)

  • @jwlzloff26
    @jwlzloff26 3 роки тому +2

    if you get a typeerror like this: "merge is not a function".
    This one helped me out:
    const { merge } = require('webpack-merge');
    The important change is the bracket pair around merge --> { merge }.

  • @KarahannAe
    @KarahannAe 4 роки тому

    9:38 The webpack logo works fine in the development server but it does not when we open the index.html file directly. Does anyone know why is that?

  • @reneeschke
    @reneeschke 5 років тому +2

    Why isn’t the ˋrunˋ-command needed for ˋnpm startˋ, when ˋnpm run buildˋ needs it?

    • @flitzepiepe1346
      @flitzepiepe1346 5 років тому +1

      stackoverflow.com/questions/51358235/difference-between-npm-start-and-npm-run-start/51358329

  • @anikamustafiz7167
    @anikamustafiz7167 3 роки тому +1

    hello Colt - would you consider doing an updated version with any changes recently made to webpack?

    • @emarekica
      @emarekica 2 роки тому +1

      You don't need it. There are very useful comments in the GitHub repo that solve all the updates needed.
      Just follow the commits and search for comments under the code:
      github.com/Colt/webpack-demo-app/commits/master

  • @sasanktadepalli1231
    @sasanktadepalli1231 4 роки тому

    Sir, I have a doubt.
    Why we are using npm start for dev
    and npm run build for production?
    What is the difference between npm and npm run?

  • @questreal5812
    @questreal5812 4 роки тому

    So putting mode: 'production' automatically minifies the js for us?

  • @ejazmuneeb
    @ejazmuneeb 2 роки тому

    you rock colt!

  • @saurabhjha575
    @saurabhjha575 4 роки тому

    Why we are using merge? can not we use Object.assign to merge two objects?

  • @lenhat7067
    @lenhat7067 4 роки тому +2

    Thank you for your course

  • @MunshiWahid
    @MunshiWahid 4 роки тому +4

    Apparently, `webpack-dev-server` with the latest version has issues and the "start" script in the `package.json` file does not work as expected in this video. Try to update the "start" script in the "package.json" with
    "webpack serve --config webpack.dev.js --open 'Google Chrome'"
    Here, "webpack serve" is the updated command instead of "webpack-dev-server"
    and "--open" needs to take an argument of browser name where you can mention 'Google Chrome'
    Another option is to add the "devServer" option to your "webpack.dev.js" file after removing the "--open" from the "start" script
    module.exports = merge(common, {
    ...
    devServer: {
    contentBase: "./dist",
    port: 3000,
    host: "127.0.0.1",
    open: true,
    },
    ...
    });
    and Thank you so much Colt for making such great videos.

  • @vidmis224
    @vidmis224 3 роки тому

    Time saving, clear af! :))

  • @shivakarthik6056
    @shivakarthik6056 4 роки тому +13

    **const { merge } = require('webpack-merge');**

  • @blank-vw2sb
    @blank-vw2sb 4 роки тому

    7:34 "Guess ive closed it down... or im blind"
    😂😂😂🤣🤣

  • @muratyayla7060
    @muratyayla7060 4 роки тому

    Getting a "Error: Cannot find module 'webpack-cli/bin/config-yargs'" after installing webpack-dev-server, make your package.json start script: "start": "webpack serve --config webpack.dev.js --open" . It may help to solve it.

  • @maxnolano
    @maxnolano 5 років тому +1

    Can you show how to use webpack or how to include angular into webpack? Thanks anyway!

    • @mns983
      @mns983 5 років тому +4

      It's already included. The angular CLI already uses webpack behind the scenes to minify the bundles and some other stuff. You might need to create a webpack config to make modifications to the default webpack settings that Angular uses. That's something Colt could show.

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

    What is the difference between using webpack-merge and lodash?

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

    How to configure .env file in webpack, so that we can get .env variables into our .js file

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

    hi dude..how to create multiple webpack file? i tried do it as the same webpack.dev.js and webpack.prod.js it shows a JS icon

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

      doesn't matter -- all that matters is what file you specify in the loading script -- they're all js, just won't give you the icon.

  • @yingwendeng1312
    @yingwendeng1312 4 роки тому

    This tutorial is amazing

  • @PareshSalunke
    @PareshSalunke 4 роки тому +2

    Big fan of your teaching, Colt. Also, a skill to learn from you.
    Secondly, for others using webpack 5 , there will be few things broken atleast for now like web-dev-serve, follow this issue to fix it. github.com/webpack/webpack-dev-server/issues/2759
    Try using `webpack serve` instead of `webpack-dev-server`

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

    Great Video!

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

    It's a very good video indeed.

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

    can i made one webpack.conf.js file build on process.env.NODE_ENV like
    if(development) {do something}
    else {do something else}
    or it's wrong and doesn't works???

    • @ColtSteeleCode
      @ColtSteeleCode  5 років тому +1

      Hi Zombie, that absolutely works! Sometimes your file can get quite large and difficult to manage if its all in one place with a bunch of env variables. But at the same time, it can be nice to see all your configuration in one place.

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

      Yeah -- I was gonna say -- I've also looked on the web and found examples using "TARGET = process.env.npm_lifecycle_event", where the lifecycle event corresponds to the script running (build, start, etc.). You could combine this way with Colt's way by having one config file that imports others and merges them based on the lifecycle hook.

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

    Awesome!!!

  • @ladyking83
    @ladyking83 3 роки тому

    webpack 5:
    npm install webpack-dev-server webpack-cli
    const { merge }= instead of const merge=
    "start": "webpack serve --config webpack.dev.js --open"

  • @ankitshaji3458
    @ankitshaji3458 Рік тому

    use lower case contenthash instead of contentHash

  • @Xenteza
    @Xenteza 5 років тому +1

    Second: D

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

    first

  • @sipry7274
    @sipry7274 3 роки тому

    I had to use "start": "webpack serve --config webpack.dev.js --open", to get it to working