/**
 * @Author: Bachir Soussi Chiadmi <bach>
 * @Date:   11-04-2017
 * @Email:  bachir@figureslibres.io
 * @Last modified by:   bach
 * @Last modified time: 16-04-2017
 * @License: GPL-V3
 */

var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  entry: ["./assets/main.js", "./assets/main.scss"],
  output: {
    path: __dirname + "/assets/dist/",
    filename: "main.js"
  },
  devtool: 'source-map',
  module: {
    rules: [
      /* your other rules for JavaScript transpiling go in here */
      {
        // regular css files
        test: /\.css$/,
        use: ExtractTextPlugin.extract({ loader: 'css-loader?importLoaders=1', }),
      },
      {
        // sass / scss loader for webpack
        test: /\.(sass|scss)$/,
        use: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
      },
      {
        // fonts
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        use: "file-loader?name=fonts/[name].[ext]"
      },
    ]
  },
  plugins: [
    new ExtractTextPlugin({
      // define where to save the file
      filename: '[name].css', allChunks: true,
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ],
  watch: true
};
