const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');

module.exports = {
  entry: [
    './src/dir/json-objects-dir.scss',
    './src/item/json-objects-item.scss'
  ],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, 'css-loader'],
      },
      {
        test: /\.(scss)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: '../../../../../public/admin-css/[name].css'
            }
          },
          {
            loader: 'extract-loader'
          },
          {
            loader: 'css-loader',
            options: {
              url: false
            }
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: { // ✅ REQUIRED in v7+
                plugins: [      // Move `plugins` inside `postcssOptions`
                  require('autoprefixer'),
                  require('cssnano') // (optional)
                ]
              }
            }
          }
          , {
            loader: 'sass-loader', options: {
              sourceMap: false,
            }
          }]
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'file-loader'
      }
    ]
  },
  resolve: {
    alias: {
      'common': path.resolve(__dirname, '../../../Common/assets'),
    },
  },
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, './garbitch')
  },
  mode: 'production',
}
