BitBagCommerce / SyliusCmsPlugin

Content management system for eCommerce apps created on Sylius platform. Built with Sylius code quality, flexibility, BDD.
MIT License
233 stars 158 forks source link

Bundle tries to load its JS resources using invalid URL #161

Closed mikemix closed 6 years ago

mikemix commented 6 years ago

When I enter any form within this bundle (either block form or page form) bundle tries to load its JS resources using invalid URL:

1. Page at: http://localhost:8080/app_dev.php/admin/pages/new

Requested resources (with 404 error): http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-page-slug.js http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-page-slug.js

2. Page at: http://localhost:8080/app_dev.php/admin/blocks/new/image

Requested resources (with 404 error): http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-block-image-preview.js http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-block-image-preview.js

Yep, both are requested twice lol. The base path for the resources should be: /bundles. This is my directory structure:

Directory structure

I'm using:

        "php": "^7.1",
        "bitbag/cms-plugin": "^1.3",
        "sylius/sylius": "1.2.*",
        "symfony/symfony": "^3.4|^4.1"
mikemix commented 6 years ago

This is how: Sylius\Bundle\ThemeBundle\Asset\Package\PathPackage works. If requested asset is not an absolute URL, it merges the path with the theme context if one is set:

        if ($this->isAbsoluteUrl($path)) {
            return $path;
        }

        $theme = $this->themeContext->getTheme();
        if (null !== $theme) {
            $path = $this->pathResolver->resolve($path, $theme);
        }
mikemix commented 6 years ago

My bad :D :dagger:

bitbager commented 6 years ago

Anyway, thanks for the information. There were many people in the community that had problems with theming in this plugin. CC @patrick477.

mikemix commented 6 years ago

Well the sylius:theme:assets:install command has to be called. I have now duplicated assets which doesn't make any sense but fkit ;)

bitbager commented 6 years ago

We will mention it in the README. Thanks!