rollup.config.js 760 B

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