file.js 520 B

1234567891011121314151617181920
  1. const { join } = require('path');
  2. const { settings } = require('../configuration');
  3. module.exports = {
  4. test: new RegExp(`(${settings.static_assets_extensions.join('|')})$`, 'i'),
  5. use: [
  6. {
  7. loader: 'file-loader',
  8. options: {
  9. name(file) {
  10. if (file.includes(settings.source_path)) {
  11. return 'media/[path][name]-[hash].[ext]';
  12. }
  13. return 'media/[folder]/[name]-[hash:8].[ext]';
  14. },
  15. context: join(settings.source_path),
  16. },
  17. },
  18. ],
  19. };