threepipe
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

vite.config.js 2.8KB

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. }
  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. preventAssignment: true,
  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. })