examples icon indicating copy to clipboard operation
examples copied to clipboard

Static Files Not Being Served

Open smazyck2 opened this issue 4 years ago • 2 comments

The Marco logo (logo.png) is not being properly served using the "fastify-static" plugin. When you start the application, the in the browser is looking for the logo at localhost:3000/logo.png which points to the root static folder at ".\static". Suffice it to say, the logo is not in that folder. Although an obvious response, would be to move the logo into the static folder, this breaks the "component-like" development pattern, and is manually intensive when there are hundreds or thousands of static images. The better resolution would be to enable the bundler to copy the static assets into another 'static folder automatically in a manner that separates each component's static assets. How can the latter be done with lasso?

smazyck2 avatar Jan 22 '22 19:01 smazyck2

@smazyck2 it appears to be working for me. The reason you do not (and should not) put the asset in a static folder is that it actually is processed by vite: https://vitejs.dev/guide/assets.html#importing-asset-as-url

DylanPiercey avatar Jan 22 '22 20:01 DylanPiercey

To clarify - I am trying to use the "lasso-fastify" example.

I guess what I'm trying to say is that the template is not working for me when I follow the installation instructions:

npx @marko/create marko-app --template lasso-fastify cd marko-app npm install npm run dev

When I try to run the web page, the image's source url is "localhost:[port]/logo.png", which does not point to the logo's file location. Are you doing something other than the instructions above to make the logo appear on the web page?

smazyck2 avatar Jan 24 '22 15:01 smazyck2