import { STATIC_ASSETS , HASH_NAME_DEV } from '../../../config/constants' ; import { imgRegex , fontRegex , mediaRegex } from '../config/regex' ; import { RuleSetRule } from '@balm-core/index' ; const imageInlineSizeLimit = parseInt ( process . env . IMAGE_INLINE_SIZE_LIMIT || '10000' ) ; function urlLoader ( ) { const PATHNAME = `${ BalmJS . config . paths . target . js }/${ STATIC_ASSETS }/` ; const FILENAME = `[name].${ HASH_NAME_DEV }.[ext]` ; const options = Object . assign ( { limit : imageInlineSizeLimit , name : BalmJS . file . assetsPath ( `${ PATHNAME }${ FILENAME }` ) , esModule : BalmJS . config . scripts . useEsModule } , BalmJS . config . scripts . urlLoaderOptions ) ; return [ { test : imgRegex , loader : require . resolve ( 'url-loader' ) , exclude : BalmJS . config . scripts . excludeUrlResource , options } , { test : mediaRegex , loader : require . resolve ( 'url-loader' ) , options } , { test : fontRegex , loader : require . resolve ( 'url-loader' ) , options } ] ; } export default urlLoader ;