Absolute Paths in Webpack
Webpack requires the path module built into NodeJS to work. Let's import it:
import 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
let 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:
let test = path.resolve('src', 'images');
console.log(test); // absolute-path/src/images
Let's see what the result of running this code will be:
let test = path.resolve('dist');
console.log(test);
Let's see what the result of running this code will be:
let test = path.resolve('dist', 'assets');
console.log(test);