threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

vite.config.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {defineConfig} from 'vite'
  2. import json from '@rollup/plugin-json';
  3. import dts from 'vite-plugin-dts'
  4. import packageJson from './package.json';
  5. import license from 'rollup-plugin-license';
  6. import replace from '@rollup/plugin-replace';
  7. import glsl from 'rollup-plugin-glsl';
  8. import path from 'node:path';
  9. const isProd = process.env.NODE_ENV === 'production'
  10. const { name, version, author } = packageJson
  11. const {main, module, browser} = packageJson
  12. export default defineConfig({
  13. optimizeDeps: {
  14. exclude: ['uiconfig.js', 'ts-browser-helpers'],
  15. },
  16. // define: {
  17. // 'process.env': process.env
  18. // },
  19. build: {
  20. sourcemap: true,
  21. minify: isProd,
  22. cssMinify: isProd,
  23. cssCodeSplit: false,
  24. watch: !isProd ? {
  25. buildDelay: 1000,
  26. } : null,
  27. lib: {
  28. entry: 'src/index.ts',
  29. formats: isProd ? ['es', 'umd'] : ['es'],
  30. name: name,
  31. fileName: (format) => (format === 'umd' ? browser : module).replace('dist/', ''),
  32. },
  33. outDir: 'dist',
  34. emptyOutDir: isProd,
  35. commonjsOptions: {
  36. exclude: [/uiconfig.js/, /ts-browser-helpers/],
  37. },
  38. rollupOptions: {
  39. output: {
  40. // inlineDynamicImports: false,
  41. },
  42. },
  43. },
  44. plugins: [
  45. isProd ? dts({tsconfigPath: './tsconfig.json'}) : null,
  46. replace({
  47. 'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'),
  48. preventAssignment: true,
  49. }),
  50. glsl({ // todo: minify glsl.
  51. include: 'src/**/*.glsl',
  52. }),
  53. json(),
  54. // postcss({
  55. // modules: false,
  56. // autoModules: true, // todo; issues with typescript import css, because inject is false
  57. // inject: false,
  58. // minimize: isProduction,
  59. // // Or with custom options for `postcss-modules`
  60. // }),
  61. license({
  62. banner: `
  63. @license
  64. ${name} v${version}
  65. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  66. ${packageJson.license} License
  67. See ./dependencies.txt for bundled third-party dependencies and licenses.
  68. `,
  69. thirdParty: {
  70. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  71. includePrivate: true, // Default is false.
  72. },
  73. }),
  74. ],
  75. })