Absolute Paths in Webpack

Webpack requires the path module built into NodeJS to work. Let's import it:

webpack.config.jsimport path from 'path';

From this module we need the method resolve. This method takes a relative path as parameters and makes it absolute from the root of the operating system

webpack.config.jslet test = path.resolve('src');
console.log(test); // absolute-path/src

You can pass multiple paths separated by commas. In this case, they will be combined with a slash:

webpack.config.jslet test = path.resolve('src', 'images');
console.log(test); // absolute-path/src/images
Задание 1

Let's see what the result of running this code will be:

webpack.config.jslet test = path.resolve('dist');
console.log(test);
Задание 2

Let's see what the result of running this code will be:

webpack.config.jslet test = path.resolve('dist', 'assets');
console.log(test);