diff options
Diffstat (limited to 'config/webpack/rules/file.js')
-rw-r--r-- | config/webpack/rules/file.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/config/webpack/rules/file.js b/config/webpack/rules/file.js new file mode 100644 index 000000000..f2fb58780 --- /dev/null +++ b/config/webpack/rules/file.js @@ -0,0 +1,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), + }, + }, + ], +}; |