Skip to content

Commit

Permalink
bugfixes, critters missing dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-reza619 committed Jan 9, 2021
1 parent 4833ea3 commit c787703
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
40 changes: 40 additions & 0 deletions contents/blog/Webpack 4/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Webpack 4 Guide
date: 2020-10-29
description: A guide for beginner around Webpack
---

So recently, i've worked on upgrading and optimizing the codebase we have at Assist ID, it was a lot of learning and a lot of fun, so i decided to write something about it.

Today, we're going to walk our way around webpack, what it is, why use it, and why it's awesome

Like any other tutorial, let's us understand what is webpack first. Webpack is a *Module Bundler*, *Module Bundler* is one of program which takes all of our JS code and non JS code (like CSS), and then Bundle them together and create a large bundler or it can be separated too.
And webpack is one the Common & Most Popular Module Bundler.

Why would we need it? Well, in today's modern world, we have to support all kinds of different browser, be it Chrome, Firefox, Safari, etc. We have to support older browser too, so that our web content can be used by all kind of different browser. And not only that, perhaps we don't want to write our Javascript in old plain Common JS, since `var` has a lot of potential to introduce bug via closure. And maybe we wanted to use a package from npm to speed up our development process.
So there you have it, there is a lot of reason to use it, but people like me tend to not using it because the config was confusing and complicated, but boy was i wrong. Turns out it really straightforward Process. Plus Webpack 4 now don't have to use any config at all. you just write your JS file inside `src/` folder, and voila, your code would be transformed by Webpack in `dist/main.js`.

With that out of the way, let's talk about fundamental things that you need to understand before using Webpack.

### Mode
Since Webpack 4, there is a new options called `mode`. This is a straightforward options, since the value would be just `production` and `development`. You would use `development`, when you develop and `production`, when you want to upload your code to production.
What's different about them is how webpack works under the hood. Development mode will set the `process.env.NODE_ENV` to `development`. But with Production mode, it will set `process.env.NODE_ENV` to `production`, and also do various optimizations out of the box for you.

The default value is `production`.

You can take a look more about this options in [Documentation](https://webpack.js.org/configuration/mode/).

```js
module.exports = {
mode: 'production',
};
```

### Entry
Entry is definitely an entry point for your code. You can point it to the base file for your code, such as `index.js`.

The default value is `./src/index.js`.

You can take a look more about this options in [Documentation](https://webpack.js.org/concepts/entry-points/).

### Output
47 changes: 46 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3046,7 +3046,7 @@ chalk@4.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^4.0.0:
chalk@^4.0.0, chalk@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a"
integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==
Expand Down Expand Up @@ -3416,6 +3416,17 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
safe-buffer "^5.0.1"
sha.js "^2.4.8"

critters@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/critters/-/critters-0.0.6.tgz#b71384113d8b5f5c82f3aeba80c122437f195d8c"
integrity sha512-NUB3Om7tkf+XWi9+2kJ2A3l4/tHORDI1UT+nHxUqay2B/tJvMpiXcklDDLBH3fPn9Pe23uu0we/08Ukjy4cLCQ==
dependencies:
chalk "^4.1.0"
css "^3.0.0"
parse5 "^6.0.1"
parse5-htmlparser2-tree-adapter "^6.0.1"
pretty-bytes "^5.3.0"

cross-fetch@3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.6.tgz#3a4040bc8941e653e0e9cf17f29ebcd177d3365c"
Expand Down Expand Up @@ -3505,6 +3516,15 @@ css@^2.0.0:
source-map-resolve "^0.5.2"
urix "^0.1.0"

css@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d"
integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ==
dependencies:
inherits "^2.0.4"
source-map "^0.6.1"
source-map-resolve "^0.6.0"

cssesc@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
Expand Down Expand Up @@ -6606,11 +6626,23 @@ parse-json@^5.0.0:
json-parse-even-better-errors "^2.3.0"
lines-and-columns "^1.1.6"

parse5-htmlparser2-tree-adapter@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6"
integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==
dependencies:
parse5 "^6.0.1"

parse5@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178"
integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==

parse5@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b"
integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==

pascalcase@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
Expand Down Expand Up @@ -6863,6 +6895,11 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=

pretty-bytes@^5.3.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.5.0.tgz#0cecda50a74a941589498011cf23275aa82b339e"
integrity sha512-p+T744ZyjjiaFlMUZZv6YPC5JrkNj8maRmPaQCWFJFplUAzpIUTRaTcS+7wmZtUoFXHtESJb23ISliaWyz3SHA==

pretty-format@^26.0.0, pretty-format@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93"
Expand Down Expand Up @@ -7747,6 +7784,14 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2:
source-map-url "^0.4.0"
urix "^0.1.0"

source-map-resolve@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2"
integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==
dependencies:
atob "^2.1.2"
decode-uri-component "^0.2.0"

source-map-support@^0.5.6, source-map-support@~0.5.12, source-map-support@~0.5.19:
version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
Expand Down

0 comments on commit c787703

Please sign in to comment.