Serving static assets in webpack dev server
You can tell webpack to use a different path when loading from the browser.
In the output
section of your webpack config file add a publicPath
field pointing to your assets
folder.
webpack.config.js
output: {
// your stuff
publicPath: '/assets/'
}
I would add that it was the opposite for me. I originally had my images and .obj/.mtl
files in a public
folder that existed at the root of my application. I moved them into an assets
folder that was created in the app
folder.
Performing an npm install --save-dev copy-webpack-plugin
and adding the
new CopyWebpackPlugin([ { from: 'src/assets', to: 'assets' } ])
to the webpack.common.js
file fixed my problem.