Skip to content
Discussion options

You must be logged in to vote

This happens because webpack-dev-server serves the public folder in development, but Webpack does not automatically copy it into dist during a production build.

You have two common solutions:

✅ Option 1 (Recommended for true static files): Use copy-webpack-plugin

If the images should stay in public and not be processed by Webpack, install:
npm install copy-webpack-plugin --save-dev

Then configure Webpack to copy the public folder into dist during build. This ensures the images exist in production exactly like they do in development.

This is the correct approach for:

  • Favicons
  • Static images
  • Robots.txt
  • Files that should not be hashed or transformed

✅ Option 2 (Recommended for app assets): …

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@yuriikinakh5
Comment options

@ye231101
Comment options

@yuriikinakh5
Comment options

@ye231101
Comment options

Comment options

You must be logged in to vote
1 reply
@yuriikinakh5
Comment options

Answer selected by yuriikinakh5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Programming Help Discussions around programming languages, open source and software development Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community!
2 participants