rollup.config.js 685 B

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