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