soapbox/webpack/rules/file.js

21 wiersze
546 B
JavaScript
Czysty Zwykły widok Historia

2020-03-27 20:59:38 +00:00
const { join } = require('path');
const { settings } = require('../configuration');
2020-03-27 20:59:38 +00:00
module.exports = {
test: new RegExp(`(${settings.static_assets_extensions.join('|')})$`, 'i'),
use: [
{
loader: 'file-loader',
options: {
name(file) {
if (file.includes(settings.source_path)) {
2021-09-05 21:42:48 +00:00
return 'packs/media/[path][name]-[contenthash].[ext]';
2020-03-27 20:59:38 +00:00
}
2021-09-05 21:42:48 +00:00
return 'packs/media/[folder]/[name]-[contenthash:8].[ext]';
2020-03-27 20:59:38 +00:00
},
context: join(settings.source_path),
},
},
],
};