⊗tlWpBsAP 10 of 55 menu

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);
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline