Gruntfile.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use strict';
  2. var fs = require('fs'),
  3. path = require('path');
  4. function findAmberPath(options) {
  5. var result;
  6. options.some(function (x) {
  7. var candidate = path.join(__dirname, x);
  8. return fs.existsSync(path.join(candidate, 'support/boot.js')) && (result = candidate);
  9. });
  10. return result;
  11. }
  12. module.exports = function (grunt) {
  13. var path = require('path');
  14. // These plugins provide necessary tasks.
  15. grunt.loadNpmTasks('grunt-contrib-requirejs');
  16. grunt.loadNpmTasks('amber-dev');
  17. // Default task.
  18. grunt.registerTask('default', ['amberc:all']);
  19. grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
  20. grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
  21. // Project configuration.
  22. grunt.initConfig({
  23. // Metadata.
  24. // pkg: grunt.file.readJSON(''),
  25. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  26. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  27. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  28. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  29. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  30. // task configuration
  31. amberc: {
  32. options: {
  33. amber_dir: findAmberPath(['../..', 'bower_components/amber']),
  34. library_dirs: ['src'],
  35. closure_jar: ''
  36. },
  37. all: {
  38. src: [
  39. 'src/Benchfib.st', 'src/Examples.st', 'src/IDE.st' // list all sources in dependency order
  40. // list all tests in dependency order
  41. ],
  42. amd_namespace: 'amber-attic',
  43. libraries: ['Web']
  44. }
  45. },
  46. amdconfig: {app: {dest: 'config.js'}},
  47. requirejs: {
  48. deploy: {options: {
  49. mainConfigFile: "config.js",
  50. onBuildWrite: function (moduleName, path, contents) {
  51. return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'deploy'}}});" : contents;
  52. },
  53. pragmas: {
  54. excludeIdeData: true,
  55. excludeDebugContexts: true
  56. },
  57. include: ['config', 'node_modules/requirejs/require', 'deploy'],
  58. out: "the.js"
  59. }},
  60. devel: {options: {
  61. mainConfigFile: "config.js",
  62. onBuildWrite: function (moduleName, path, contents) {
  63. return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'devel'}}});" : contents;
  64. },
  65. include: ['config', 'node_modules/requirejs/require'],
  66. out: "the.js"
  67. }}
  68. }
  69. });
  70. };