Gruntfile.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict';
  2. module.exports = function(grunt) {
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. babel: {
  6. options: {
  7. presets: ['@babel/preset-env']
  8. },
  9. dist: {
  10. files: [{
  11. expand: 'true',
  12. cwd: 'src/js',
  13. src: ['*.js', '**/*.js'],
  14. dest: 'dist/'
  15. }]
  16. }
  17. },
  18. browserify: {
  19. adapterGlobalObject: {
  20. src: ['./dist/adapter_core5.js'],
  21. dest: './out/adapter.js',
  22. options: {
  23. browserifyOptions: {
  24. // Exposes shim methods in a global object to the browser.
  25. // The tests require this.
  26. standalone: 'adapter'
  27. }
  28. }
  29. },
  30. // Use this if you do not want adapter to expose anything to the global
  31. // scope.
  32. adapterAndNoGlobalObject: {
  33. src: ['./dist/adapter_core5.js'],
  34. dest: './out/adapter_no_global.js'
  35. }
  36. },
  37. eslint: {
  38. options: {
  39. overrideConfigFile: '.eslintrc'
  40. },
  41. target: ['src/**/*.js', 'test/*.js', 'test/unit/*.js', 'test/e2e/*.js']
  42. },
  43. copy: {
  44. build: {
  45. dest: 'release/',
  46. cwd: 'out',
  47. src: '**',
  48. nonull: true,
  49. expand: true
  50. }
  51. },
  52. shell: {
  53. downloadBrowser : {
  54. command: 'BROWSER=${BROWSER-chrome} BVER=${BVER-stable} ./node_modules/travis-multirunner/setup.sh'
  55. },
  56. },
  57. });
  58. grunt.loadNpmTasks('grunt-eslint');
  59. grunt.loadNpmTasks('grunt-browserify');
  60. grunt.loadNpmTasks('grunt-babel');
  61. grunt.loadNpmTasks('grunt-contrib-copy');
  62. grunt.loadNpmTasks('grunt-shell');
  63. grunt.registerTask('default', ['eslint', 'build']);
  64. grunt.registerTask('lint', ['eslint']);
  65. grunt.registerTask('build', ['babel', 'browserify']);
  66. grunt.registerTask('copyForPublish', ['copy']);
  67. grunt.registerTask('downloadBrowser', ['shell:downloadBrowser'])
  68. };