-
Hi Rob My coworker is using tailwind and defined a custom component like this:
This all works and pointing to the correct assets when But at this point any reference to an asset (image/svg) in the js of css file like this: Because those assets are not moved when doing I fixed this by adding this to the vite.config.js file
I hope this all makes sense :) Ps, when using the statamic asset/svg tag there is no issue because it looks in the /resources folder for its asset and does it's magic. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey yeah, it makes sense. Make sure you reference assets like the following example in your JS/CSS files. This way Vite to updates the URL and copies the assets over to the build folder: plugin(function({ addComponents, theme }) {
const components = {
'.test': {
backgroundImage: 'url(/public/path/to/file.svg)',
},
}
addComponents(components)
}) You can also reference the resources folder like this: The config changes aren't needed this way. Hope it helps! |
Beta Was this translation helpful? Give feedback.
Hey yeah, it makes sense. Make sure you reference assets like the following example in your JS/CSS files. This way Vite to updates the URL and copies the assets over to the build folder:
You can also reference the resources folder like this:
/resources/svg/file.svg
.The config changes aren't needed this way. Hope it helps!