threepipe
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

vite.config.js 2.7KB

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