const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractSass = new ExtractTextPlugin({ filename: 'style.css', allChunks: true });

var sourceMap = '';
if (process.env.NODE_ENV !== 'production') {
  sourceMap = '#inline-source-map';
}

const plugins = [
  new webpack.ProvidePlugin({
    jQuery: 'jquery',
    $: 'jquery',
    jquery: 'jquery',
    Tether: 'tether',
  }),
  new webpack.DefinePlugin({ ENV: JSON.stringify(process.env.NODE_ENV) }),
];

if (process.env.NODE_ENV === 'production') {
  plugins.push(new webpack.optimize.UglifyJsPlugin());
}


module.exports = [
  // JS
  {
    context: `${__dirname}/src`,
    entry: {
      background: './chrome/background',
      browser_action: './chrome/browser_action',
      inject: './chrome/inject',
      options: './option',
    },
    output: {
      path: `${__dirname}/dist`,
      filename: '[name].js',
    },
    plugins,
    module: {
      loaders: [
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          query: {
            presets: ['es2015', 'react'],
            plugins: ['transform-flow-strip-types'],
          },
        },
      ],
    },
    resolve: {
      extensions: ['.js', '.jsx'],
    },
    devtool: sourceMap,
  },


  // SCSS
  {
    context: `${__dirname}/src`,
    entry: {
      style: './chrome/static/style/index.js',
    },
    output: {
      path: `${__dirname}/dist`,
      filename: '[name].js',
    },
    module: {
      loaders: [
        {
          test: /\.scss$/,
          loader: ExtractTextPlugin.extract('css-loader!sass-loader'),
        },
        {
          test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
          loader: 'url-loader?limit=10000&mimetype=application/font-woff',
        }, {
          test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
          loader: 'url-loader?limit=10000&mimetype=application/font-woff',
        }, {
          test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
          loader: 'url-loader?limit=10000&mimetype=application/octet-stream',
        }, {
          test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
          loader: 'file-loader',
        }, {
          test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
          loader: 'url-loader?limit=10000&mimetype=image/svg+xml',
        }
      ],
    },
    plugins: [
      extractSass,
      new CopyWebpackPlugin([
        { from: 'chrome/static/html' },
      ]),
    ],
  },
];

@@ -558,16 +558,99 @@
 NV) %7D),%0A
+  extractSass,%0A  new CopyWebpackPlugin(%5B%0A    %7B from: 'chrome/static/html' %7D,%0A  %5D),%0A
 %5D;%0A%0Aif (
@@ -772,16 +772,8 @@
 = %5B%0A
-  // JS%0A
   %7B%0A
@@ -964,24 +964,71 @@
 './option',%0A
+      style: './chrome/static/style/index.js',%0A
     %7D,%0A    o
@@ -1397,340 +1397,8 @@
  %7D,%0A
-      %5D,%0A    %7D,%0A    resolve: %7B%0A      extensions: %5B'.js', '.jsx'%5D,%0A    %7D,%0A    devtool: sourceMap,%0A  %7D,%0A%0A%0A  // SCSS%0A  %7B%0A    context: %60$%7B__dirname%7D/src%60,%0A    entry: %7B%0A      style: './chrome/static/style/index.js',%0A    %7D,%0A    output: %7B%0A      path: %60$%7B__dirname%7D/dist%60,%0A      filename: '%5Bname%5D.js',%0A    %7D,%0A    module: %7B%0A      loaders: %5B%0A
     
@@ -1485,16 +1485,25 @@
 s-loader
+?minimize
 !sass-lo
@@ -1655,32 +1655,40 @@
 off',%0A        %7D,
+%0A       
  %7B%0A          tes
@@ -1799,32 +1799,40 @@
 off',%0A        %7D,
+%0A       
  %7B%0A          tes
@@ -1944,32 +1944,40 @@
 eam',%0A        %7D,
+%0A       
  %7B%0A          tes
@@ -2052,16 +2052,24 @@
       %7D,
+%0A       
  %7B%0A     
@@ -2185,16 +2185,17 @@
        %7D
+,
 %0A      %5D
@@ -2207,26 +2207,26 @@
  %7D,%0A    
-plugins: %5B
+resolve: %7B
 %0A      e
@@ -2231,103 +2231,80 @@
  ext
-ractSass,%0A      new CopyWebpackPlugin(%5B%0A        %7B from: 'chrome/static/html' %7D
+ensions: %5B'.js', '.jsx', '.scss', '.css'%5D
 ,%0A    
-  %5D)
+%7D
 ,%0A    
-%5D
+devtool: sourceMap
 ,%0A  

Integrate css settings and minimize