bundle.js 959 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const fs = require('fs');
  2. const path = require('path');
  3. const requirejs = require('requirejs');
  4. function dir( file ) {
  5. return path.resolve( __dirname, file );
  6. }
  7. // get banner
  8. let dbillyJsSrc = fs.readFileSync( dir('../draggabilly.js'), 'utf8' );
  9. let banner = dbillyJsSrc.split(' */')[0] + ' */\n\n';
  10. banner = banner.replace( 'Draggabilly', 'Draggabilly PACKAGED' );
  11. let options = {
  12. out: dir('../dist/draggabilly.pkgd.js'),
  13. baseUrl: 'node_modules',
  14. optimize: 'none',
  15. include: [
  16. 'jquery-bridget/jquery-bridget',
  17. 'draggabilly/draggabilly',
  18. ],
  19. paths: {
  20. draggabilly: '../',
  21. jquery: 'empty:',
  22. },
  23. };
  24. requirejs.optimize(
  25. options,
  26. function() {
  27. let content = fs.readFileSync( options.out, 'utf8' );
  28. content = content.replace( "'draggabilly/draggabilly',", '' );
  29. content = banner + content;
  30. fs.writeFileSync( options.out, content );
  31. },
  32. function( err ) {
  33. throw new Error( err );
  34. },
  35. );