[英]I've written my own npm module, when I import it into a new project, all the asset paths are relative toward the project instead of inside the module?
As an example, I have a couple of icons that are used inside the module, however the path '../../public/assets/arrow.svg' works when running the module directly, however when importing it into a project, the module is now trying to find the SVG inside the projects public folder instead.例如,我在模块内部使用了几个图标,但是路径“../../public/assets/arrow.svg”在直接运行模块时有效,但是在将其导入项目时,该模块现在尝试在项目公共文件夹中查找 SVG。 How is this usually handled?
这通常是如何处理的?
Hello and welcome to stack overflow.您好,欢迎堆栈溢出。 The paths that you are using are relative to your current directory.
您使用的路径相对于您的当前目录。 I would recommend you prepend the base directory of your module or something similar to this.
我建议您预先添加模块的基本目录或类似的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.