如何解决使用ng-packagr构建角度库时,导入SVG文件会出错
我正在使用nx monorepo,我的一个库正在将SVG文件导入到JS文件之一中。一切正常,但是当我尝试使用ng-packagr构建我的库时,它给我一个错误-
“错误:无法从dist / libs / bpo-ui-base / esm2015 / ui / src / lib / hierarchy / config.js中解析“ ./svgs/default.svg””
config.js
import defaultSVG from './svgs/default.svg'
const styleArray = {
dagre: [
{
selector: 'node',style: {
'background-image': defaultSVG,'background-image-opacity': 1,'background-fit': 'contain','background-clip': 'none',content: 'data(name)','text-valign': 'center','background-opacity': 0,'text-wrap': 'ellipsis','text-max-width': '50px','font-size': '8px',color: '#6A737A','text-halign': 'center','text-margin-x': '0px','text-margin-y': '22px','text-background-color': '#fff','text-background-opacity': 0,'text-border-style': 'solid','text-border-width': '0.2px','text-border-color': '#000','text-border-opacity': 0,'text-background-padding': '1px'
}
}
]
}
export {
styleArray
}
default.svg
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Created using Krita: http://krita.org -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:krita="http://krita.org/namespaces/svg/krita"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
width="126.72pt"
height="132.48pt"
viewBox="0 0 126.72 132.48">
<defs/>
<ellipse id="shape0" transform="translate(13.8686300612321,16.3237336435986)" rx="49.4913699387679" ry="48.8419731722839" cx="49.4913699387679" cy="48.8419731722839" fill="none" stroke="#777" stroke-width="18.6696" stroke-linecap="square" stroke-linejoin="bevel"/>
</svg>
文件夹结构
-apps
-libs
-- lib1
-- lib2
-- src
-- lib
-- folder1
-- folder2
-- svgs
-- default.svg
-- config.js
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。