Webpack Tutorial for Beginners #3 - The webpack.config File

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ • 36

  • @TheTanadu
    @TheTanadu 6 років тому +4

    For everyone who are stuck there - use package "path" to get absolute path of dist folder - for example:
    const path = require('path');
    const entryPoint = 'src/script-1.js';
    const outputPoint = 'dist';
    module.exports = {
    //define entry point
    entry: path.resolve(__dirname, entryPoint),
    //define output
    output: {
    path: path.resolve(__dirname, outputPoint),
    filename: 'bundle.js'
    }
    };
    You don't need to add path with npm, because webpack bring it with him it. (From 3+ version it's required)

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

    For those people having problem with path...
    const path = require("path");
    module.exports = {
    mode : "development",
    //Define an entry point
    entry: "./src/script-1.js",
    //Define an output point
    output: {
    path : path.resolve("./dist"),
    filename : "bundle.js"
    }
    };

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

    This was extremely helpful and well explained. Thank you for taking the time to make these tutorials.

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

    I really like his little intro with the ninja.

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

    output: {
    path: require('path').resolve("./dist"),
    filename: 'bundle.js'
    }

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

    so I moved on from Lesson 2 as per a suggested comment.
    Unfortunately, got stuck again.
    This time after inputting 'webpack' in terminal get alot of RED:
    [webpack-cli] Failed to load E:\ **my path**\webpack-playlist\webpack.config.js config
    [webpack-cli] ReferenceError: modules is not defined...
    anyone? Have things changes so drastically from 2016 to 2021 that this tute is not longer valid?

  • @virenbhagat4966
    @virenbhagat4966 7 років тому +8

    Receiving an error after setting up webpack.config.js and trying to run webpack to create dist folder and bundle. Error is "Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
    - configuration.output.path: The provided value "dist" is not an absolute path!"

    • @earlhansgenoso5929
      @earlhansgenoso5929 7 років тому +14

      try this code ..
      output: {
      path: __dirname + "/dist", // or path: path.join(__dirname, "dist/js"),
      filename: "bundle.js"
      }

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

      // another working example
      const path = require('path');
      module.exports = {
      entry: "./src/script-1.js",
      output: {
      path: path.resolve('./dist'),
      filename: 'bundle.js'}};

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

      thank you

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

      this one works!thank you so much!

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

      @ Solaire Phantom thanks. this code worked.

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

    Hi,I am using vuejs with webpack.When i run webpack it compile all javascript+css+vuejs code in one file.But actually i want to load specific javascript for each component.For example if i click and call login component then only call login.css and particular javascript.But webpack combine all script in one file and load all code at once even those code which i don't need on require page.

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

    can you please help me what web server you have used for video, it will automatically refresh browser while you change in the code

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

    Sauce folder :D .... Love your videos shaun. Thank you so much for making these

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

    I got this error when I run webpack
    "Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
    - configuration.output.path: The provided value "dist" is not an absolute path!"
    .
    How should I solve this?

  • @sickboy1432
    @sickboy1432 6 років тому +4

    If you are receiving an error message about the path use this:
    output: {
    path: `${__dirname}/dist`,
    filename: "bundle.js"
    }

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

    Hi, what's the font used for you IDE? It looks good. :)

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

    Thanks for your video.Very well explanation :)

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

    hi, what is this font that you use on your text editor ?

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

    Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
    - configuration.output.path: The provided value "dist" is not an absolute path!

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

    output file name not configured

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

      smart playa I was having the same error, found out you have to name the config file like "webpack.config.js" so the ".js" was missing, after fixing this it all went smoothly.

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

      thanks i figured it out. I just named it webpack.js without the config

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

      i changed the file name and it's still giving me the same message. help ?

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

      Name it webpack.config.js

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

      thanks!!

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

    Man! This was driving me mad.. I could not figure out what i was doing wrong. I finally realized the .gitignore file was hiding the dist folder from me in atom. The exercise files come with node_modules and dist folder hidden, so if you run webpack and it appears to have worked, but you dont see the dist folder, and you are using atom... just remove it from .gitignore. I used the following code:
    const path = require('path');
    module.exports = {
    entry: "./src/script-1.js",
    output: {
    path: path.resolve('./dist'),
    filename: 'bundle.js'}};

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

    Receiving an error then
    try this code ..
    output: {
    path: __dirname + "/dist", // or path: path.join(__dirname, "dist/js"),
    filename: "bundle.js"
    }
    credits: #Earl Hans Geñoso(do like his comment ,he deserves it)

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

    2:20 RIP earphone users