import { AngularExternalStyles , AngularExternalResource } from '../external-resources/angular-external-resources.interfaces' ; import { CSSTransformer } from '../languages/css.transformer' ; import { getFileType } from '../../utilities/get-file-type' ; import { SASSTransformer } from '../languages/sass.transformer' ; /**
 * Angular External Styles Transformer
 */ export class AngularExternalStylesTransformer { param externalStyles param externalStyle param style public static async inlineExternalStyle ( externalStyles , externalStyle , style ) { const preparedStyle = await this . prepareStyle ( style , getFileType ( externalStyle . path ) ) ; externalStyles . node . replaceWithText ( 'styles' ) ; externalStyle . node . replaceWithText ( `'${ preparedStyle }'` ) ; } param style param fileType returns private static async prepareStyle ( style , fileType ) { switch ( fileType ) { case 'css' : case 'scss' : case 'sass' : return CSSTransformer . minify ( await SASSTransformer . compileToCss ( style ) ) ; default : throw new Error ( `Angular Package Builder: The file type "${ fileType }" is not supported for external styles.` ) ; } } }