Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get wrong output path in webpack file loader

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.

like image 237
FNGR Avatar asked Dec 15 '17 08:12

FNGR


1 Answers

I've already commented. But every question should have an answer.

test: /\.(jpg|png|svg)$/,
use: 'file-loader?name=[name].[ext]&outputPath=./images/'
like image 110
Pravesh Khatri Avatar answered Oct 27 '22 00:10

Pravesh Khatri