0

I'm getting no prefixes with these setup. Cssnano and write to style.css is working but there is no prefixes added from my sass to css.

I'm just started with webpack so maybe I'm just not gettings it.

Config:

var development = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
var precss       = require('precss');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var cssnano = require('cssnano');
var autoprefixer = require('autoprefixer');


var extractCSS = new ExtractTextPlugin('style.css');


module.exports = [
  {
  name: 'app-bundle',
  entry: "./src/js/main.js",
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel-loader',
      },
    ]
  },
  output: {
    path: "",
    filename: "bundle.min.js"
  },
  plugins: development ? [
  ]: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
},


{
  name: 'css/scss',
  entry:  './src/sass/style.scss',
  module: {
  loaders:
    [
      {
      test: /\.scss$/,
      loader: extractCSS.extract('style', 'css!postcss!sass')
      }
    ]
  },
  postcss: function(webpack)
    {
    returnĀ [
      cssnano({
         autoprefixer: {
           add: true,
           remove: false,
           browsers: [
            'last 2 versions',
            'ie >= 9'
          ]
         },
         discardComments: {
           removeAll: true
         },
         discardUnused: false,
         mergeIdents: false,
         reduceIdents: false,
         safe: true,
         sourcemap: true
     })
   ]
 },
  output: {
    path: "",
    filename: "style.css"
  },
  plugins: development ? [
    extractCSS
  ] : []
}
];
MonkeyBizz
  • 111
  • 3
  • 6

1 Answers1

0

There is a problem with your postcss plugin declaration

 postcss: function(webpack)
{
return [
  autoprefixer(), // Should be a function call and not reside inside cssnano config
  cssnano({
     discardComments: {
       removeAll: true
     },
     discardUnused: false,
     mergeIdents: false,
     reduceIdents: false,
     safe: true,
     sourcemap: true
 }),

] },