# CSS aus einem Plugin einbinden

**URL:** <https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030>\
**Category:** Shopware 5\
**Created:** [22. Oktober 2021 um 07:01 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030 "2021-10-22T07:01:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [22. Oktober 2021 um 07:01 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030/1 "2021-10-22T07:01:34Z")

</div>

Aktuell nutze ich diesen Pfad für die Einbindung einer puren CSS Resource:

[https://example.com/custom/plugins/MeinPlugin/Resources/Themes/Frontend/MeinTheme/frontend/\_public/src/css/style.css](https://example.com/custom/plugins/MeinPlugin/Resources/Themes/Frontend/MeinTheme/frontend/_public/src/css/style.css)

Ich bin mir unsicher ob das so korrekt ist, ging das nicht mal kürzer?

Danke und Gruss.

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [22. Oktober 2021 um 07:17 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030/2 "2021-10-22T07:17:43Z")

</div>

Tust du nicht in deinem Plugin den Pfad definieren? Dann geht es auch kürzer.

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [22. Oktober 2021 um 07:19 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030/3 "2021-10-22T07:19:50Z")

</div>

Das verstehe ich gerade nicht, hast du ein Beispiel?

Danke und Gruss

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [22. Oktober 2021 um 07:23 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030/4 "2021-10-22T07:23:55Z")

</div>

Mal so auf die schnelle:

```auto
use Shopware\Components\Theme\LessDefinition;
use Doctrine\Common\Collections\ArrayCollection;

...

public static function getSubscribedEvents() {
  $events = Array(
  'Theme_Compiler_Collect_Plugin_Less' => 'addLess',
  );
  return $events;
}

...

public function addLess() {
  $f = new LessDefinition([], [__DIR__. '/Resources/Views/src/less/all.less'], __DIR__ );
  return new ArrayCollection([$f]);
}

```

Ok, ich arbeite allerdings nur mit LESS nicht mit CSS, aber ich denke da sollte es ähnlich aussehen.

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [22. Oktober 2021 um 07:24 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030/5 "2021-10-22T07:24:59Z")

</div>

Danke, das gucke ich mir mal genauer an.

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [22. Oktober 2021 um 09:37 UTC](https://forum.shopware.com/t/css-aus-einem-plugin-einbinden/91030/6 "2021-10-22T09:37:55Z")

</div>

Da kommt mir gerade die Idee, dass ich das mit Less machen werde und in die LESS lade ich die CSS, dann habe ich auch nicht das Problem, dass der Cache im Browser immer neu geladen muss bei CSS-Änderungen.
