question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error compiling less files with imports wihout extension (less without mix/webpack works)

See original GitHub issue
  • Laravel Mix Version: 1.5.0
  • Node Version (node -v): v6.10.2
  • NPM Version (npm -v): 5.4.2
  • OS: Ubuntu
  • less: “^3.0.0-alpha.3”

Description:

I’m using AdminLTE with Laravel mix. I don’t know why but compilation with Laravel Mix stop to work. It seems the problem is with imports without .less extension

Steps To Reproduce:

You can use this repo:

https://github.com/acacha/AdminLTETinkerLaravelMix

webpack.mix.js File (https://github.com/acacha/AdminLTETinkerLaravelMix/blob/master/webpack.mix.js):

mix.less('build/less/AdminLTE.less','public/css')

AdminLTE.less file (https://github.com/acacha/AdminLTETinkerLaravelMix/blob/master/build/less/AdminLTE.less) have imports without .less extension like:

@import "print";

Clone repo, npm install and run:

$ npm run dev

> admin-lte@2.4.2 dev /home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                      

 ERROR  Failed to compile with 2 errors                                                                    17:58:40

 error  in ./build/less/AdminLTE.less

Module build failed: 

@import "miscellaneous";
@import "print";
^
Can't resolve './print' in '/home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/build/less'
      in /home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/build/less/AdminLTE.less (line 62, column 0)

 @ ./build/less/AdminLTE.less 4:14-200
 @ multi ./node_modules/laravel-mix/src/builder/mock-entry.js ./build/less/AdminLTE.less

 error  in ./build/less/AdminLTE.less

Module build failed: ModuleBuildError: Module build failed: 

@import "miscellaneous";
@import "print";
^
Can't resolve './print' in '/home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/build/less'
      in /home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/build/less/AdminLTE.less (line 62, column 0)
    at runLoaders (/home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/node_modules/webpack/lib/NormalModule.js:195:19)
    at /home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/home/sergi/Code/almasaeed2010/AdminLTETinkerLaravelMix/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at process._tickCallback (internal/process/next_tick.js:109:7)

 Asset     Size  Chunks             Chunk Names
mix.js  3.58 kB       0  [emitted]  mix
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! admin-lte@2.4.2 dev: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the admin-lte@2.4.2 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sergi/.npm/_logs/2017-10-11T15_58_40_789Z-debug.log

Note that:

lessc build/less/AdminLTE.less

Works without any problem.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
robhuzzeycommented, Oct 12, 2017

@legreco regarding your issue with the .less extensions… you could try

resolve: {
      extensions: ['.js', '.json', '.less']
    }

in your webpack config as that way if you try to include without extensions it will try those extensions (if that makes sense).

2reactions
JeffreyWaycommented, Oct 17, 2017

So should we add .less to that extension array and be done with it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error compiling less files with imports wihout extension (less ...
I don't know why but compilation with Laravel Mix stop to work. It... ... work. It seems the problem is with imports without...
Read more >
less-loader | webpack - JS.ORG
Prepends/Appends Less code to the actual entry file. In this case, the less-loader will not override the source but just prepend the entry's...
Read more >
Webpack does not resolve less loader - Stack Overflow
After countless hours I now receive following error: ERROR in ./node_modules/antd/lib/button/style/index.less 1:0 Module parse failed: ...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Learn how to use Rollup as a smaller, more efficient alternative to webpack and Browserify to bundle JavaScript files in this step-by-step tutorial...
Read more >
Laravel Mix - CSS and Java Compilation Made Easy
Yes, npm required extra empty -- argument to work. Webpack is watching for file changes. At this point, Laravel Mix is ready to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found