shopware - 在 Shopware 6 中使用 scss 中的资产
问题描述
我无法在 scss 中将图像作为背景图像插入。我的主题中有图像:custom/plugins/MyTheme/src/Resources/app/storefront/src/assets/img/my-image.png
并且我正在尝试在 scss 文件中使用此图像。当我使用时,./psh.phar storefront:build
我可以在店面中看到图像,但是当我使用时./psh.phar storefront:hot-proxy
出现错误:
This relative module was not found: * ../assets/img/my-image.png in ./node_modules/css-loader/dist/cjs.js??ref--8-1!./node_modules/postcss-loader/src??ref--8-2!./node_modules/sass-loader/lib/loader.js??ref--8-3!/app/var/theme-entry.scss
在 scss 我使用路径:background-image: url("../assets/img/my-image.png");
如何在scss中正确添加文件?
解决方案
您需要将文件相对于主题 css,然后直接从那里引用。像“图像/abc.jpg”。
推荐阅读
- gitlab - 如何从 gitlab-ci.yml 在 Gitlab CI/CD 中保存新变量
- python - pandas 按顺序分组
- javascript - 来自示例代码片段的日期差异的时区偏移量
- c - 未对齐的数据类型是否在基于 ARM 的系统上正确存储和检索?
- dll - 我尝试制作 dll 文件时 Visual Studio 2019 中的错误
- wordpress - 无法创建谷歌云 DNS
- python - 功能无法正常工作,python,pygame
- android - 使用 Xposed 逆向工程应用程序
- python - Python unittest 在独立测试用例之间共享对象属性
- docker - 散景独立图表在泊坞窗中不起作用