首页 > 解决方案 > 在 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中正确添加文件?

标签: shopwareshopware6

解决方案


您需要将文件相对于主题 css,然后直接从那里引用。像“图像/abc.jpg”。


推荐阅读