rollup.unit.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. try {
  2. require( 'qunit' );
  3. } catch {
  4. console.log( '\x1b[31mError! You not installed dependencies. Please run `npm i --prefix test`\x1b[37m' );
  5. process.exit( 1 );
  6. }
  7. function glsl() {
  8. return {
  9. transform( code, id ) {
  10. if ( /\.glsl$/.test( id ) === false ) 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. // example unit conf
  26. {
  27. input: 'unit/three.example.unit.js',
  28. plugins: [
  29. glsl()
  30. ],
  31. // sourceMap: true,
  32. output: [
  33. {
  34. format: 'umd',
  35. name: 'THREE',
  36. file: 'unit/build/three.example.unit.js',
  37. intro: 'QUnit.module( "Example", () => {',
  38. outro: '} );',
  39. indent: '\t',
  40. }
  41. ]
  42. },
  43. // source unit conf
  44. {
  45. input: 'unit/three.source.unit.js',
  46. plugins: [
  47. glsl()
  48. ],
  49. // sourceMap: true,
  50. output: [
  51. {
  52. format: 'umd',
  53. name: 'THREE',
  54. file: 'unit/build/three.source.unit.js',
  55. intro: 'QUnit.module( "Source", () => {',
  56. outro: '} );',
  57. indent: '\t',
  58. }
  59. ]
  60. },
  61. ];