import type * as d from './declarations' ; import * as path from 'path' ; export function usePlugin ( fileName ) { return /(\.css|\.pcss|\.postcss)$/i . test ( fileName ) ; } export function getRenderOptions ( opts , sourceText , context ) { const renderOpts = { plugins : opts . plugins || [ ] , } ; renderOpts . data = sourceText || '' ; const injectGlobalPaths = Array . isArray ( opts . injectGlobalPaths ) ? opts . injectGlobalPaths . slice ( ) : [ ] ; if ( injectGlobalPaths . length > 0 ) { const injectText = injectGlobalPaths . map ( ( injectGlobalPath ) => { if ( ! path . isAbsolute ( injectGlobalPath ) ) { injectGlobalPath = path . join ( context . config . rootDir , injectGlobalPath ) ; } return `@import "${ injectGlobalPath }";` ; } ) . join ( '' ) ; renderOpts . data = injectText + renderOpts . data ; } return renderOpts ; } export function createResultsId ( fileName ) { const pathParts = fileName . split ( '.' ) ; pathParts [ pathParts . length - 1 ] = 'css' ; return pathParts . join ( '.' ) ; }