Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

项目配置css module影响到css-loader对第三方库css文件中图片url的处理 #3950

Closed
wonyun opened this issue Feb 1, 2020 · 0 comments

Comments

@wonyun
Copy link

wonyun commented Feb 1, 2020

What happens?

  • 通过设置cssLoaderOptions.modules为true来开启项目的css modules
  • 项目中引入第三方库中的css文件,如:
      import 'kindeditor/themes/default/default.css'
  • 第三方库中的css样式中背景引入图片,该图片地址形式为:
    .xxx {
      background: url(background.png);
      ...
    }

然后执行npm start编译报错:

 ERROR  Failed to compile with 1 errors

 error  in ./node_modules/kindeditor/themes/default/default.css

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleNotFoundError: Module not found: Error: Can't resolve 'background.png' in '/Users/Desktop/study/umi-question-report/node_modules/kindeditor/themes/default'
    at factory.create (/Users/Desktop/study/umi-question-report/node_modules/webpack/lib/Compilation.js:925:10)
    at factory (/Users/Desktop/study/umi-question-report/node_modules/webpack/lib/NormalModuleFactory.js:401:22)
    at resolver (/Users/Desktop/study/umi-question-report/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
    at asyncLib.parallel (/Users/Desktop/study/umi-question-report/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
    at /Users/Desktop/study/umi-question-report/node_modules/neo-async/async.js:2830:7
    at /Users/Desktop/study/umi-question-report/node_modules/neo-async/async.js:6877:13
    at normalResolver.resolve (/Users/Desktop/study/umi-question-report/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
    at doResolve (/Users/Desktop/study/umi-question-report/node_modules/enhanced-resolve/lib/Resolver.js:213:14)
    at hook.callAsync (/Users/Desktop/study/umi-question-report/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/Users/Desktop/study/umi-question-report/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)

 @ ./src/pages/index.tsx 3:0-47
 @ ./src/pages/.umi/router.js
 @ ./src/pages/.umi/umi.js
 @ multi ./node_modules/af-webpack/lib/webpackHotDevClient.js ./src/pages/.umi/umi.js

最小可复现仓库

具体的复现代码仓库:https://github.com/wonyun/umi-question-report
readme.md描述的比较详细

相关环境信息

  • Umi 版本:2.9.0
  • Node 版本:10.16.0
  • 操作系统:MacBook Pro OS X EI Caption 10.11.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants