const IS_JS_RE = /\.[cm]?js(\?[^.]+)?$/ ; const IS_MODULE_RE = /\.mjs(\?[^.]+)?$/ ; const HAS_EXT_RE = /[^./]+\.[^./]+$/ ; const IS_CSS_RE = /\.(css|postcss|sass|scss|less|stylus|styl)(\?[^.]+)?$/ ; export function isJS ( file ) { return IS_JS_RE . test ( file ) || ! HAS_EXT_RE . test ( file ) ; } export function isModule ( file ) { return IS_MODULE_RE . test ( file ) || ! HAS_EXT_RE . test ( file ) ; } export function isCSS ( file ) { return IS_CSS_RE . test ( file ) ; } export function getExtension ( file ) { const withoutQuery = file . replace ( /\?.*/ , '' ) ; return withoutQuery . split ( '.' ) . pop ( ) || '' ; } export function ensureTrailingSlash ( path ) { if ( path === '' ) { return path ; } return path . replace ( /([^/])$/ , '$1/' ) ; } export function getPreloadType ( ext ) { if ( ext === 'js' || ext === 'cjs' || ext === 'mjs' ) { return 'script' ; } else if ( ext === 'css' ) { return 'style' ; } else if ( /jpe?g|png|svg|gif|webp|ico/ . test ( ext ) ) { return 'image' ; } else if ( /woff2?|ttf|otf|eot/ . test ( ext ) ) { return 'font' ; } else { return undefined ; } }