1

Hey guys (using webpack 2.1.0-beta.22) so I have the following config in my webpack.base.js:

entry: {
    client: "./client/index.js"
},
output: {
    path: _.outputPath,
    filename: '[name].js',
    publicPath: '/themes/default/dist/'
},
module: {
    loaders: [
        {
            test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
            loader: 'file',
            query: {
                name: 'media/[name].[hash:8].[ext]'
            }
        }
    ]
}

And this in my webpack.dev.js:

const cssImagePath = path.resolve('../..');`

base.module.loaders.push(
    {
        test: /\.(s?)css$/,
        loaders: [
            'style-loader',
            `css-loader?sourceMap&root=${cssImagePath}`,
            'sass-loader?outputStyle=expanded&sourceMap&sourceMapContents'
        ]
    }
)

Now I have this line in my scss file: background-image: url('/themes/default/client/images/snow-flake.png');

If I run webpack and use the inspector the path is being replaced to this: url(/themes/default/dist/media/snow-flake.0af467e3.png)

Which looks perfect problem is the file-loader is not creating / copying to that directory so themes/default/dist/media does not exist?

Anyone came across this?

Otis Wright
  • 1,980
  • 8
  • 31
  • 53
  • were you able to resolve this? I am using beta 25 – Rohan Nov 21 '16 at 18:01
  • I came across with similar problem. File loader was working fine in my case. I was using webpack-dev-server command which only generates file in memory rather than emitting it. You can check if you are doing the same. – Ankit Sharma Jul 03 '17 at 08:01

0 Answers0