Webpack / PostCSS - OptimiseCssAssetsPlugin阻止CSS Sourcemap在浏览器中可用

时间:2016-05-31 11:23:11

标签: css webpack source-maps postcss

我正在尝试在webpack中使用OptimiseCssAssetsPlugin,但是当我介绍它时,我的css源图(看起来仍然会生成)在chrome中不再可用。

我的webpack.config.js是以下

const webpack = require('webpack');
const path = require('path');
var precss       = require('precss');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var postcssImport = require('postcss-import');
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');

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?sourceMap&importLoaders=1!postcss-loader')
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin("si-styles.css"),
    new OptimizeCssAssetsPlugin()
  ],
   postcss: function(webpack) {
        return [
            postcssImport({ addDependencyTo: webpack }), // Must be first item in list
            precss,
            autoprefixer({ browsers: ['last 2 versions']  })
        ];
    },

}

对此的任何想法都将不胜感激。

0 个答案:

没有答案