当我尝试将资产导入我的 .less 文件时,请帮助我解决 ModuleNotFoundError。
看起来问题是css-loader,有人可以帮助我优雅地解决这个问题。
git hub 上的问题链接:https ://github.com/webpack-contrib/css-loader/issues/682
请找到
- 变量.less
- common.less
- webpack.config.js
- 错误日志
common.less
@import "variables.less";
// Global Styles
* {
outline: none !important;
}
body {
background: @sidebar;
font-family: @basefont1;
margin: 0;
overflow-x: hidden;
color: @bodytext;
font-weight: 300;
}
**variables.less**
//Path of current-file
///home/sujeet/projects/src/module-front/libs/ample-admin/ampleadmin-minimal
// Variables
@import url(https://fonts.googleapis.com/css?family=Rubik:300,400,500,700,900);
@import "icons/font-awesome/less/font-awesome.less";
@basefont1:'Rubik', sans-serif;
@basefont2:'Rubik', sans-serif;
webpack.conif.js
{
test: /\.less$/,
loader: ExtractTextPlugin.extract({
use: [{
loader: 'css-loader',
},
{
loader: 'less-loader',
options: {
paths: [path.resolve(__dirname, "node_modules")],
}
}
],
fallback: 'style-loader'
// ,publicPath:publicPath_Css
})
}
错误日志
ERROR in ./libs/ample-admin/ampleadmin-minimal/less/common.less
Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve './icons/font-awesome/less/icons/font-awesome/fonts/fontawesome-webfont.eot' in '/home/sujeet/projects/src/module-front/libs/ample-admin/ampleadmin-minimal/less'
at factoryCallback (/home/sujeet/projects/src/module-front/node_modules/webpack/lib/Compilation.js:276:40)
at factory (/home/sujeet/projects/src/module-front/node_modules/webpack/lib/NormalModuleFactory.js:237:20)
at resolver (/home/sujeet/projects/src/module-front/node_modules/webpack/lib/NormalModuleFactory.js:60:20)
at asyncLib.parallel.e (/home/sujeet/projects/src/module-front/node_modules/webpack/lib/NormalModuleFactory.js:127:20)
at /home/sujeet/projects/src/module-front/node_modules/async/dist/async.js:3874:9
at /home/sujeet/projects/src/module-front/node_modules/async/dist/async.js:473:16
at iteratorCallback (/home/sujeet/projects/src/module-front/node_modules/async/dist/async.js:1048:13)
at /home/sujeet/projects/src/module-front/node_modules/async/dist/async.js:958:16
at /home/sujeet/projects/src/module-front/node_modules/async/dist/async.js:3871:13
at resolvers.normal.resolve (/home/sujeet/projects/src/module-front/node_modules/webpack/lib/NormalModuleFactory.js:119:22)
at onError (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:65:10)
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at runAfter (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:158:4)
at innerCallback (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:146:3)
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/home/sujeet/projects/src/module-front/node_modules/tapable/lib/Tapable.js:252:11)
at /home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:40:4
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at runAfter (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:158:4)
at innerCallback (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:146:3)
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/home/sujeet/projects/src/module-front/node_modules/tapable/lib/Tapable.js:252:11)
at innerCallback (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:144:11)
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/home/sujeet/projects/src/module-front/node_modules/tapable/lib/Tapable.js:249:35)
at resolver.doResolve.createInnerCallback (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:44:6)
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at afterInnerCallback (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/Resolver.js:168:10)
at loggingCallbackWrapper (/home/sujeet/projects/src/module-front/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/home/sujeet/projects/src/module-front/node_modules/tapable/lib/Tapable.js:252:11)
@ ./libs/ample-admin/ampleadmin-minimal/less/common.less
@ ./src/apps/home/home.app.js