Skip to content

Static Assets (for example: Images) #16

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

Closed
nullsumme opened this issue Jan 25, 2016 · 5 comments
Closed

Static Assets (for example: Images) #16

nullsumme opened this issue Jan 25, 2016 · 5 comments

Comments

@nullsumme
Copy link

Hey,

Thanks a lot for this great "starter" application. Since I'm very new to all of this I have a small quastion:
What do we need to add so we can access static files like images?

@nullsumme
Copy link
Author

Okay, looks like for development we can use something like this:

app.use('/images', express.static(__dirname + '/assets/images'));

@geowarin
Copy link
Owner

The best way IMHO is to use the URL loader of webpack.
I pushed a branch demoing that (requiring the image)

This way, you will have all your assets passed through webpack. You can do many types of optimizations from here.

With your method, keep in mind that you will also have to figure out a way to put the images in the public directory of the application's jar in prod. It can be as simple as simply putting them here in the first place.

@nullsumme
Copy link
Author

Thanks for the reply.
With this way I can access the files via webpack, thats fine. But what can I do if i need the image for some CSS stuff like 'background: url()?

@geowarin
Copy link
Owner

This should automatically work: see the section about urls of the css loader.

@nullsumme
Copy link
Author

Perfect! You are right, it works just like that.
Thanks a lot.

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

2 participants