threepipe
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vite.config.js 3.0KB

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