@flatjs/evolve 2.1.0-next.19 → 2.1.0-next.20
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
import{dirname,join,relative,resolve}from"node:path";import{resolvePublicPath}from"../resolve-public-path.js";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"./constants.js";import{isIconSvg}from"./rule-utils.js";const getEntryAssetFileName=(e,t,r)=>{
|
1
|
+
import{dirname,join,relative,resolve}from"node:path";import{ensureSlash}from"@flatjs/common";import{resolvePublicPath}from"../resolve-public-path.js";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"./constants.js";import{isIconSvg}from"./rule-utils.js";const getEntryAssetFileName=(e,t,r)=>{const{projectCwd:o,projectVirtualPath:s}=r;let n=dirname(join(s,e.replace(/^src/,"")));const a=[];for(const[e,r]of t)for(const t of r.entry)a.push({entryName:e,entry:t});a.sort(((e,t)=>t.entry.length-e.entry.length));for(const t of a){const{entryName:r,entry:s}=t,a=dirname(join(o,s)),i=resolve(o,e);if(i.startsWith(ensureSlash(a,!0))){n=dirname(join(r,relative(a,i)));break}}return`${n}/[name]-[contenthash:8][ext]`};export const ruleAssets=(e,t)=>{const r=resolvePublicPath(t);return{type:"asset",test:e=>FONT_PATH_REGEX.test(e)||IMAGE_PATH_REGEX.test(e)&&!isIconSvg(e),generator:{filename:({filename:r})=>getEntryAssetFileName(r,e,t),publicPath:"auto"===r?void 0:r},parser:{dataUrlCondition:{maxSize:t.loaderOptions.assetDataUrlMaxSize}}}};
|