Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative path of node_modules for LESS @import

Tags:

less

Say I have the following structure

/node_modules
/src
   /components
      /component1
         /style
            /style.less

Now I want to import some LESS file from node_modules/some-module/style.less; I'd have to do something like @import '../../../../node_modules/some-module/style.less

Is there no short hand notation so that the path is relative to project folder? Something like @import ~/node_modules/some-module/style.less?

like image 445
Kousha Avatar asked May 13 '17 19:05

Kousha


1 Answers

You can achieve this by installing less-loader and add it into webpack.

How to do it: https://www.npmjs.com/package/less-loader#webpack-resolver

Example:

@import "~font-awesome/css/font-awesome.min.css";
like image 131
ArtixZ Avatar answered Jan 04 '23 04:01

ArtixZ