const path = require('path');
const paths = require('../paths');
const jsonImporter = require('node-sass-json-importer')

const sassLoader = {
  loader: 'sass-loader',
  options: {
    includePaths: [paths.app.cssBase, 'node_modules'],
    importer: jsonImporter
  }
}

const postcssLoader = {
  loader: 'postcss-loader',
  options: {
    config: {
      path: path.resolve('.config/postcss.config.js')
    }
  }
}

// Note that svg fonts won't be picked up by this loader
const fontLoader = () => ({
  test: /\.(ttf|eot|woff|woff2)$/,
  use: {
    loader: 'file-loader',
    options: {
      name: 'fonts/[name].[ext]'
    }
  }
})


const imageLoader = ({ isProd, assetHash }) => ({
  test: /\.(gif|png|jpe?g|svg)$/i,
  use: [
    {
      loader: 'file-loader',
      options: {
        name: isProd ? '[hash].[ext]' : '[path][name].[ext]',
        outputPath: '/files/',
        publicPath: assetHash + '/files/',
        context: 'frontend'
      }
    },
    {
      loader: 'image-webpack-loader',
      options: {
        disable: true, // disabled in dev mode
        optipng: {
          enabled: false
        },
        pngquant: {
          quality: '90-95'
        }
      }
    }
  ]
})

module.exports = {
  sassLoader: sassLoader,
  postcssLoader: postcssLoader,
  fontLoader: fontLoader,
  imageLoader: imageLoader,
}

@@ -21,17 +21,16 @@
 ('path')
-;
 %0Aconst p
@@ -59,9 +59,8 @@
 hs')
-;
 %0Acon
@@ -168,24 +168,45 @@
  options: %7B%0A
+    sassOptions: %7B%0A  
     includeP
@@ -252,16 +252,18 @@
 '%5D,%0A    
+  
 importer
@@ -276,20 +276,29 @@
 Importer
-%0A  %7D
+,%0A    %7D,%0A  %7D,
 %0A%7D%0A%0Acons
@@ -362,22 +362,30 @@
 : %7B%0A    
-config
+postcssOptions
 : %7B%0A    
@@ -386,20 +386,22 @@
 %7B%0A      
-path
+config
 : path.r
@@ -435,26 +435,29 @@
 fig.js')
+,
 %0A    %7D
+,
 %0A  %7D
+,
 %0A%7D%0A%0A// N
@@ -659,24 +659,26 @@
 xt%5D'
+,
 %0A    %7D
+,
 %0A  %7D
+,
 %0A%7D)%0A%0A
-%0A
 cons
@@ -982,24 +982,25 @@
 rontend'
+,
 %0A      %7D
 %0A    %7D,%0A
@@ -987,24 +987,25 @@
 nd',%0A      %7D
+,
 %0A    %7D,%0A    
@@ -1151,16 +1151,17 @@
 d: false
+,
 %0A       
@@ -1210,16 +1210,17 @@
  '90-95'
+,
 %0A       
@@ -1221,24 +1221,25 @@
        %7D
+,
 %0A      %7D
 %0A    %7D%0A 
@@ -1234,18 +1234,21 @@
    %7D
+,
 %0A    %7D
+,
 %0A  %5D
+,
 %0A%7D)%0A

Update webpack config