rollup.config.js 695 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import * as fs from 'fs';
  2. var outro = `
  3. Object.defineProperty( exports, 'AudioContext', {
  4. get: function () {
  5. return exports.getAudioContext();
  6. }
  7. });`;
  8. var footer = fs.readFileSync( 'src/Three.Legacy.js', 'utf-8' );
  9. function glsl () {
  10. return {
  11. transform ( code, id ) {
  12. if ( !/\.glsl$/.test( id ) ) return;
  13. return 'export default ' + JSON.stringify(
  14. code
  15. .replace( /[ \t]*\/\/.*\n/g, '' )
  16. .replace( /[ \t]*\/\*[\s\S]*?\*\//g, '' )
  17. .replace( /\n{2,}/g, '\n' )
  18. ) + ';';
  19. }
  20. };
  21. }
  22. export default {
  23. entry: 'src/Three.js',
  24. dest: 'build/three.js',
  25. moduleName: 'THREE',
  26. format: 'umd',
  27. indent: '\t',
  28. plugins: [
  29. glsl()
  30. ],
  31. outro: outro,
  32. footer: footer
  33. };