rollup.unit.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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, '' )
  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. // editor unit conf
  20. {
  21. input: 'test/three.editor.unit.js',
  22. indent: '\t',
  23. plugins: [
  24. glsl()
  25. ],
  26. // sourceMap: true,
  27. output: [
  28. {
  29. format: 'umd',
  30. name: 'THREE',
  31. file: 'test/unit/three.editor.unit.js',
  32. intro: 'QUnit.module( "Editor", () => {',
  33. outro: '} );',
  34. }
  35. ]
  36. },
  37. // example unit conf
  38. {
  39. input: 'test/three.example.unit.js',
  40. indent: '\t',
  41. plugins: [
  42. glsl()
  43. ],
  44. // sourceMap: true,
  45. output: [
  46. {
  47. format: 'umd',
  48. name: 'THREE',
  49. file: 'test/unit/three.example.unit.js',
  50. intro: 'QUnit.module( "Example", () => {',
  51. outro: '} );',
  52. }
  53. ]
  54. },
  55. // source unit conf
  56. {
  57. input: 'test/three.source.unit.js',
  58. indent: '\t',
  59. plugins: [
  60. glsl()
  61. ],
  62. // sourceMap: true,
  63. output: [
  64. {
  65. format: 'umd',
  66. name: 'THREE',
  67. file: 'test/unit/three.source.unit.js',
  68. intro: 'QUnit.module( "Source", () => {',
  69. outro: '} );',
  70. }
  71. ]
  72. },
  73. ];