styleImport.ts 543 B

1234567891011121314151617181920212223
  1. /**
  2. * Introduces component library styles on demand.
  3. * https://github.com/anncwb/vite-plugin-style-import
  4. */
  5. import styleImport from 'vite-plugin-style-import';
  6. export function configStyleImportPlugin(isBuild: boolean) {
  7. if (!isBuild) {
  8. return [];
  9. }
  10. const styleImportPlugin = styleImport({
  11. libs: [
  12. {
  13. libraryName: 'ant-design-vue',
  14. esModule: true,
  15. resolveStyle: (name) => {
  16. return `ant-design-vue/es/${name}/style/index`;
  17. },
  18. },
  19. ],
  20. });
  21. return styleImportPlugin;
  22. }