I have read that in order to have source maps, I have to use absolute urls in the url('')
statement.
I did it this way :
body
background-image: url('/elements/assets/tmp_background.jpg')
It works when I remove the sourceMap option from the css loader, it does not if I activate it.
I think I might have failed somewhere on the absolute path point, do you have any ideas?
Here is my config file :
module.exports = {
devtool: 'source-map',
entry: [
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:8080',
path.resolve(__dirname, 'elements/main.js'),
],
output: {
path: 'dist',
publicPath: '/', // Prefix for all the statics urls
filename: 'bundle.js',
},
resolve: {
root: path.resolve(__dirname),
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015',
},
{ test: /\.css$/, loaders: ['style', 'css'] },
{ test: /\.scss$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap'] },
{ test: /\.sass$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap&indentedSyntax=true'] },
{ test: /\.jade$/, loaders: ['ngtemplate', 'html', 'jade-html'] },
{ test: /\.(png|gif|jp(e)?g)$/, loader: 'url-loader?limit=8192' },
{ test: /\.(ttf|eot|svg|woff(2))(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=50000' },
],
},
};
On a more general idea, I could not find a working example of what I'm trying to do. I would be very interested if you can redirect me to that.
The publicPath
can be used to fix this, until a cleaner solution appears.
See https://github.com/webpack/css-loader/issues/29
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