css.d.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. /// <reference types="node" />
  2. import { Plugin } from 'vite';
  3. import { OutputOptions } from 'rollup';
  4. export declare function uniCssPlugin(): Plugin;
  5. /**
  6. * converts the source filepath of the asset to the output filename based on the assetFileNames option. \
  7. * this function imitates the behavior of rollup.js. \
  8. * https://rollupjs.org/guide/en/#outputassetfilenames
  9. *
  10. * @example
  11. * ```ts
  12. * const content = Buffer.from('text');
  13. * const fileName = assetFileNamesToFileName(
  14. * 'assets/[name].[hash][extname]',
  15. * '/path/to/file.txt',
  16. * getAssetHash(content),
  17. * content
  18. * )
  19. * // fileName: 'assets/file.982d9e3e.txt'
  20. * ```
  21. *
  22. * @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
  23. * @param file filepath of the asset
  24. * @param contentHash hash of the asset. used for `'[hash]'` placeholder
  25. * @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
  26. * @returns output filename
  27. */
  28. export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;