WebPack 4 Flashcards

1
Q

What is webpack?

A

Webpack is a build tool that allows us to take all of our assets and turn them into a production-ready bundle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are all of our files considered in webpack?

A

Modules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are top three benefits of working with webpack?

A
  1. Require assets, load when needed
  2. Code splitting – load only the code that the page requires, minimise initial loading time.
  3. Transformations – React/ES6 to vanilla JS, Sass/Less to CSS, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s new in webpack 4?

Give 4 answers.

A
  1. No more support for Node.js 4
  2. Up to 98% faster
  3. Dev and production mode
  4. Support for WebAssembly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s the difference between dev and production mode?

A

In production mode, the build size is prioritised.

In dev mode, the speed of the build is optimised.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you run webpack in watch mode?

A

By using the -w flag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the default config for webpack?

A

webpack.config.js

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you specify a custom config file for webpack?

A

By using the –config flag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do webpack loaders help us with?

Give 3 answers.

A
  1. Perform transformations on files
  2. Help load files and images
  3. Deal with dialects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you specify the starting file of your project in the webpack config?

A

By using the ‘entry’ key inside module.exports

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you specify the output file for your project in the webpack config?

A

By using the ‘output’ key inside module.exports to specify an object with two keys: ‘filename’ and ‘path’. ‘filename’ is the name of the file wherease the ‘path’ is where to put this file, which you can specify by using path.resolve and passing it two parameters: __dirname and the name of the folder you want to be created at the root of the project for bundling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you specify what loaders to use and how in webpack config?

A

By using the ‘module’ key inside module.exports object and assigning it an object with the key ‘rules’, which is an array containing objects. In each object, you create a ‘test’ key to specify the filter for which files to use the loader for and ‘use’ to specify which loaders to use. Use is an array of objects that each has a key of ‘loader’, specifying the name of the loader. You can also use the ‘exclude’ key in rule objects to specify what file/folders to exclude. For example, commonly, you exclude node_modules from the babel-loader.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What webpack loaders can you use to load .css files?

A

style-loader and css-loader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What webpack loader can you use to load images?

A

url-loader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does code splitting do?

A

It breaks up your code into different bundles. This can be done using multiple entrypoints.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly