Reputation: 1067
I am trying to generate a css sourcemap from webpack. However, currently the css.map
file that is generate is largely empty.
{"version":3,"sources":[],"names":[],"mappings":"","file":"si-styles.css","sourceRoot":""}
I understand that I need to add something similar to the below
css-loader?sourceMap
But I am unsure how I chain this with importLoaders = 1, which I currently have within my webpack.config.js
.
const webpack = require('webpack');
const path = require('path');
//post css
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var postcssImport = require('postcss-import');
module.exports = {
context: __dirname + '/frontend',
devtool: 'source-map',
entry: "./index.js",
output: {
filename: 'bundle.js',
path: path.join(__dirname, './static')
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015']
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', '!css-loader?importLoaders=1!postcss-loader')
}
]
},
plugins: [
new ExtractTextPlugin("si-styles.css")
],
// postcss: [
// precss,
// autoprefixer({ browsers: ['last 2 versions'] })
// ]
postcss: function(webpack) {
return [
postcssImport({ addDependencyTo: webpack }), // Must be first item in list
precss,
autoprefixer({ browsers: ['last 2 versions'] })
];
},
}
Upvotes: 1
Views: 2419
Reputation: 1067
I just found an example with the correct way to do this. I have used '&' to chain together ie
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', '!css-loader?sourceMap&importLoaders=1!postcss-loader')
}
Upvotes: 2