Reputation: 192
I'm using Angular5 and webpack for generate the dist folder. For generating the assets folder i'm using the "copy-webpack-plugin". It copies the assets folder from /src/assets into /dist folder. The problem is: all the path used by a admin console template of my src code uses relative paths starting from "assets/..." and the server include /dist/assets. All static resources will throw 404 not found. What is the best way to include an assets folder into a dist folder?
Upvotes: 0
Views: 1337
Reputation: 5384
I would recommend using the file-loader
designed for this very purpose.
Once you have it configured in your webpack.config.js
you can import paths to your files for use in JavaScript, as well as HTML templates if you're also using the html-loader
.
const myImageUrl = require('./path/to/an/image.png')
doSomething(myImageUrl)
Upvotes: 1