marko-js / examples

55 stars 36 forks source link

Static Files Not Being Served #23

Open smazyck2 opened 2 years ago

smazyck2 commented 2 years ago

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?

DylanPiercey commented 2 years ago

@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

smazyck2 commented 2 years ago

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?