You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vite.config.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import react from '@vitejs/plugin-react';
  21. import autoprefixer from 'autoprefixer';
  22. import { resolve } from 'node:path';
  23. import postCssCalc from 'postcss-calc';
  24. import postCssCustomProperties from 'postcss-custom-properties';
  25. import tailwind from 'tailwindcss';
  26. import { defineConfig } from 'vite';
  27. import dts from 'vite-plugin-dts';
  28. import { getCustomProperties } from '../config/utils';
  29. import babelConfig from './babel.config';
  30. import * as packageJson from './package.json';
  31. const customProperties = getCustomProperties();
  32. // https://vitejs.dev/config/
  33. export default defineConfig({
  34. build: {
  35. lib: {
  36. entry: resolve('src', 'index.ts'),
  37. name: 'MIUI',
  38. formats: ['es'],
  39. fileName: (_format) => `index.js`,
  40. },
  41. outDir: 'lib',
  42. rollupOptions: {
  43. external: [...Object.keys(packageJson.peerDependencies)],
  44. },
  45. },
  46. css: {
  47. postcss: {
  48. plugins: [
  49. tailwind('../tailwind.config.js'),
  50. autoprefixer,
  51. postCssCustomProperties({
  52. importFrom: { customProperties },
  53. preserve: false,
  54. }),
  55. postCssCalc,
  56. ],
  57. },
  58. },
  59. esbuild: {
  60. // https://github.com/vitejs/vite/issues/8644#issuecomment-1159308803
  61. logOverride: { 'this-is-undefined-in-esm': 'silent' },
  62. },
  63. optimizeDeps: {
  64. esbuildOptions: {
  65. target: 'es2022',
  66. },
  67. },
  68. plugins: [
  69. react({
  70. babel: babelConfig,
  71. }),
  72. dts({
  73. entryRoot: 'src',
  74. }),
  75. ],
  76. });