about summary refs log tree commit diff
path: root/config/webpack/rules/file.js
blob: f2fb58780103f96193efafa75738a7b495b70717 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const { join } = require('path');
const { settings } = require('../configuration');

module.exports = {
  test: new RegExp(`(${settings.static_assets_extensions.join('|')})$`, 'i'),
  use: [
    {
      loader: 'file-loader',
      options: {
        name(file) {
          if (file.includes(settings.source_path)) {
            return 'media/[path][name]-[hash].[ext]';
          }
          return 'media/[folder]/[name]-[hash:8].[ext]';
        },
        context: join(settings.source_path),
      },
    },
  ],
};