rollup.config.js 613 B

12345678910111213141516171819202122232425262728293031323334353637
  1. function glsl () {
  2. return {
  3. transform ( code, id ) {
  4. if ( !/\.glsl$/.test( id ) ) return;
  5. var transformedCode = 'export default ' + JSON.stringify(
  6. code
  7. .replace( /[ \t]*\/\/.*\n/g, '' )
  8. .replace( /[ \t]*\/\*[\s\S]*?\*\//g, '' )
  9. .replace( /\n{2,}/g, '\n' )
  10. ) + ';';
  11. return {
  12. code: transformedCode,
  13. map: { mappings: '' }
  14. }
  15. }
  16. };
  17. }
  18. export default {
  19. entry: 'src/Three.js',
  20. indent: '\t',
  21. plugins: [
  22. glsl()
  23. ],
  24. targets: [
  25. {
  26. format: 'umd',
  27. moduleName: 'THREE',
  28. dest: 'build/three.js'
  29. },
  30. {
  31. format: 'es',
  32. dest: 'build/three.module.js'
  33. }
  34. ]
  35. };