// See the shakacode/shakapacker README and docs directory for advice on customizing your webpackConfig.
const { generateWebpackConfig, merge, mergeWithRules } = require('shakapacker')
const cssConfig = require('./rules/css')
const svgConfig = require('./rules/svg')
const vueConfig = require('./rules/vue')

const webpackConfig = generateWebpackConfig()

let conf = merge(vueConfig, svgConfig);
conf = merge(cssConfig, conf);
conf = merge(conf, webpackConfig);

const updateFileLoaderConf = {
  module: {
    rules: [
      {
        type: 'asset/resource',
        // This version does not include svg. See https://github.com/shakacode/shakapacker/blob/v6.2.0/package/rules/file.js
        test: /\.(bmp|gif|jpe?g|png|tiff|ico|avif|webp|eot|otf|ttf|woff|woff2)$/
      }
    ]
  }
}

conf = mergeWithRules({
  module: {
    rules: {
      type: "match",
      test: "replace"
    }
  }
})(conf, updateFileLoaderConf);

module.exports = conf
