SoFunction
Updated on 2025-04-11

Introducing less file in vue component Module build failed

The error occurs like this:

//Introduce less file in vue component<style lang="less">
 @import '@/assets/css/public/';
</style>

Then there was an error:

Module build failed:
@import '@/assets/css/public/';
^
Can't resolve './@/assets/css/public/' in 'D:\mt\src\layout'
   in D:\mt\src\layout\ (line 23, column 0)
   ...
   ...
   ...

As a beginner vue, I was really confused when I saw this error. I fought hard for a day, and I had been on Baidu for a day. Vue was loading and unloading, uninstalling, and I really wanted to find a piece of tofu to kill him...

Then suddenly something was wrong

seemingly'@/assets/css/public/'@ in YesAliases defined in the /src directory in '.js', '.vue', '.json' seem to be difficult to use in less files

then……

<style lang="less">
 @import '../assets/css/public/';
</style>

Finally, the world is peaceful

Summarize

The above is the introduction of the less file in the vue component introduced to you. Module build failed. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!