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

2 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. '@threepipe/plugin-tweakpane': '@threepipe/plugin-tweakpane',
  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 ? ['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. plugins: [
  53. isProd ? dts({tsconfigPath: './tsconfig.json'}) : null,
  54. replace({
  55. 'from \'three\'': 'from \'threepipe\'',
  56. delimiters: ['', ''],
  57. }),
  58. replace({
  59. 'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'),
  60. preventAssignment: true,
  61. }),
  62. glsl({ // todo: minify glsl.
  63. include: 'src/**/*.glsl',
  64. }),
  65. json(),
  66. // postcss({
  67. // modules: false,
  68. // autoModules: true, // todo; issues with typescript import css, because inject is false
  69. // inject: false,
  70. // minimize: isProduction,
  71. // // Or with custom options for `postcss-modules`
  72. // }),
  73. license({
  74. banner: `
  75. @license
  76. ${name} v${version}
  77. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  78. ${packageJson.license} License
  79. See ./dependencies.txt for any bundled third-party dependencies and licenses.
  80. `,
  81. thirdParty: {
  82. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  83. includePrivate: true, // Default is false.
  84. },
  85. }),
  86. ],
  87. })