threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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