Compiling less with webpack
13,167
A couple of things needed to be corrected:
-
Add
require('./myPath/myFile.less')
to yourapp.js
(or entry point).The less file does not go in the index.html file.
-
You need a few dependencies. The versions I used are:
"less": "^2.7.1", "less-loader": "^2.2.3", "style-loader": "^0.13.1", "css-loader": "^0.23.1",
Author by
yairr
Recently used Angular, C# .NET Core, Java, JavaScript, Decision Trees for AI B.S. Computer Science. Microsoft Certified Professional.
Updated on June 07, 2022Comments
-
yairr almost 2 years
I want to add a very basic less file to my project on github (see this commit).
style.less
body { background-color: red; }
webpack.config.js
{ test: /\.less$/, loaders: ['style', 'css', 'less'] }
Command line build command
webpack --config webpack.config.js -d
Index.html
<link rel="stylesheet" href="css/bundle.less" />
I expected the deployment folder to now contain bundle.css which contains the contents of my less file. This did not happen.
How do I setup webpack to compile my less?
-
CharlesTWall3 over 5 yearsRe: #1 I am amazed this detail isn't in the docs. StackOverflow saves the day again. For those using typescript: stackoverflow.com/questions/44064890/…