Skip to content

Static Assets (for example: Images) #16

Closed

Description

@nullsumme

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?

Activity

  1. nullsumme commented on Jan 25, 2016

    @nullsumme
    Author

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

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

  2. geowarin commented on Jan 25, 2016

    @geowarin
    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.

  3. nullsumme commented on Jan 25, 2016

    @nullsumme
    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()?

  4. geowarin commented on Jan 25, 2016

    @geowarin
    Owner

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

  5. nullsumme commented on Jan 26, 2016

    @nullsumme
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions