NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.41k stars 4.78k forks source link

引用nutui vue3 icon组件,tarojs 3.5.6 执行npm run build:h5 -- --watch,报错postcss-url: Image type is svg and link contains #. Postcss-url cant handle svg fragments. #14035

Open maouxu opened 1 year ago

maouxu commented 1 year ago

相关平台

H5

浏览器版本: Microsoft Edge 版本 114.0.1823.43 (正式版本) (64 位) 使用框架: Vue 3

复现步骤

使用nutui icon的方案一 引入 iconfont,执行npm run build:h5 -- --watch,报错(3:3) postcss-url: Image type is svg and link contains #. Postcss-url cant handle svg fragments. SVG file fully inlined. E:\project\nov_web_mp\src\assets\iconfont\iconfont.svg

期望结果

可以正常编译

实际结果

编译报错(3:3) postcss-url: Image type is svg and link contains #. Postcss-url cant handle svg fragments. SVG file fully inlined. E:\project\nov_web_mp\src\assets\iconfont\iconfont.svg

环境信息

  Taro CLI 3.5.11 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.14.0 - C:\Users\84441\AppData\Local\Temp\yarn--1686910179596-0.29573092973060056\node.CMD
      Yarn: 1.22.19 - C:\Users\84441\AppData\Local\Temp\yarn--1686910179596-0.29573092973060056\yarn.CMD
      npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD

补充信息

在config.index.js中的 h5:{ postcss:{ url:{ config:{ filter: () => { return /^.*.(svg|png)$/; } } } } } 增加这个后还是报错

maouxu commented 1 year ago

Compiled with problems:X

WARNING in ./src/assets/iconfont/iconfont.css (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-4.use[0]!./node_modules/@tarojs/webpack5-runner/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-5.use[0]!./src/assets/iconfont/iconfont.css)

Module Warning (from ./node_modules/@tarojs/webpack5-runner/node_modules/postcss-loader/dist/cjs.js): Warning

(3:3) postcss-url: Image type is svg and link contains #. Postcss-url cant handle svg fragments. SVG file fully inlined. E:\project\nov_web_mp\src\assets\iconfont\iconfont.svg

WARNING in ./src/assets/iconfont/iconfont.css (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-4.use[0]!./node_modules/@tarojs/webpack5-runner/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-5.use[0]!./src/assets/iconfont/iconfont.css)

Module Warning (from ./node_modules/@tarojs/webpack5-runner/node_modules/postcss-loader/dist/cjs.js): Warning

(3:3) postcss-url: Image type is svg and link contains #. Postcss-url cant handle svg fragments. SVG file fully inlined. E:\project\nov_web_mp\src\assets\iconfont\iconfont.svg