Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing css background images during dev #20

Open
szyam opened this issue Feb 22, 2024 · 5 comments
Open

Showing css background images during dev #20

szyam opened this issue Feb 22, 2024 · 5 comments

Comments

@szyam
Copy link

szyam commented Feb 22, 2024

First off, huge thanks to blonsetar for putting this together, I got it up and running relatively easily.

With the inc.vite updates in the other issue I have both running good locally, and pushing code to my server set to production mode is working good too.

One thing I haven't been able to do yet is to see css background images while in dev mode locally... Im assuming its a path I have to edit in the config but am new to vite, any suggestions?

@TommyKolkman
Copy link

This is a problem for me too. Any idea?

@szyam
Copy link
Author

szyam commented Apr 2, 2024

Unfortunately no, I experimented a bit but did not have luck. Ive used for two small projects and neither had many bg images so I worked around it. Still trying to add css source maps as well.

@goodjobjohn
Copy link

does this answer help? #7 (comment)

@animexxx
Copy link

animexxx commented Jul 20, 2024

Still unstable, the background image not working and the import script and style on production got error also. i think im back to tailpress
update fix:
put the image background like this: /wp-content/themes/wp-theme-vite-tailwind-main/assets/img/your_image_url.jpg
in inc.vite.php replace block with:
` if (is_array($manifest)) {
// get first key, by default is 'main.js' but it can change
//$manifest_key = array_keys($manifest);

        foreach (@$manifest['main.js']['css'] as $css_file) {
            wp_enqueue_style('main', DIST_URI . '/' . $css_file);
        }

        // enqueue main JS file
        $js_file = @$manifest['main.js']['file'];
        if (!empty($js_file)) {
            wp_enqueue_script('main', DIST_URI . '/' . $js_file, JS_DEPENDENCY, '', JS_LOAD_IN_FOOTER);
        }
    }`

@szyam
Copy link
Author

szyam commented Jul 25, 2024

I tried a few different things, but wasn't finding a good method. Just recently I tried just letting the 'wp-content' version roll through my build, I received an error that the files were not created and left alone, which is fine since I dont want my images being rebuilt every time, but when I deployed it worked as expected. So, my current css variables look like this:

--gray-texture: url('/wp-content/themes/redwood-living/assets/icons/grey-bg-texture.svg');
--wood-texture: url('/wp-content/themes/redwood-living/assets/icons/prefooter-texture.svg');
--top-texture: url('/wp-content/themes/redwood-living/assets/icons/top-texture.svg');

This is being rendered in my built css file, now Im going to try to remove the warning from my build process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants