I can't get webpack (3.10) file-loader paths to work how I need it.. Here is an extract of my webpack.config.js
// ...
const images = {
test: /\.(jpg|png|svg)$/,
use: {
loader: 'file-loader',
options: {
name: 'images/[path][name].[hash].[ext]',
},
},
}
//...
const config = {
entry: {
App: './public/assets/js/main.js',
},
output: {
path: path.resolve(__dirname, 'public', 'assets', 'dist'),
filename: 'main.js',
},
module: {
rules: [javascript, styles, images],
},
plugins: [new ExtractTextPlugin('main.css'), uglify],
}
//...
I want my images to be in /public/assets/dist/images/XXX.svg
but they're beeing loaded into /public/assets/dist/images/public/assets/images/XXX.svg
I really don't get it... thank you for every help.
I've already commented. But every question should have an answer.
test: /\.(jpg|png|svg)$/,
use: 'file-loader?name=[name].[ext]&outputPath=./images/'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With