Gruntfile.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. module.exports = function (grunt) {
  2. // load all grunt tasks
  3. require('jit-grunt')(grunt);
  4. grunt.initConfig({
  5. clean: {
  6. init: ['dist/libs/inspector.js', 'dist/libs/main.css', 'dist/inspector.js', 'dist/inspector.d.ts'],
  7. compilation: ['dist/inspector/', 'dist/libs/inspector.js', 'dist/libs/main.css']
  8. },
  9. // Compilation from TypeScript to ES5²
  10. ts: {
  11. inspector: {
  12. src : ['ts/**/*.ts', 'ts/typings/**/*'],
  13. outDir: "dist",
  14. options:{
  15. module: 'amd',
  16. target: 'es5',
  17. declaration: true,
  18. sourceMap:true,
  19. removeComments:false
  20. }
  21. }
  22. },
  23. // Concat definition files
  24. concat: {
  25. inspector: {
  26. files: {
  27. 'dist/inspector.d.ts': ['dist/inspector/**/*.d.ts']
  28. },
  29. },
  30. },
  31. // Watches content related changes
  32. watch : {
  33. inspector : {
  34. files: ['ts/inspector/**/*.ts'],
  35. tasks: ['ts']
  36. },
  37. test : {
  38. files: ['ts/test/**/*.ts'],
  39. tasks: ['ts']
  40. },
  41. sass : {
  42. files: ['sass/**/*.scss'],
  43. tasks: ['sass','postcss']
  44. }
  45. },
  46. // Sass compilation. Produce an extended css file in css folder
  47. sass : {
  48. options: {
  49. sourcemap:'none',
  50. style: 'expanded'
  51. },
  52. dist : {
  53. files: {
  54. 'dist/libs/main.css': 'sass/main.scss'
  55. }
  56. }
  57. },
  58. // Auto prefixer css
  59. postcss : {
  60. dist: {
  61. options: {
  62. processors: [
  63. require('autoprefixer')({browsers: 'last 2 versions'}),
  64. require('cssnano')()
  65. ]
  66. },
  67. src: 'dist/libs/main.css'
  68. }
  69. },
  70. // Build dist version
  71. uglify : {
  72. dist: {
  73. options: {
  74. compress:false,
  75. beautify: true
  76. },
  77. files: {
  78. 'dist/libs/inspector.js': [
  79. 'dist/inspector/gui/BasicElement.js',
  80. 'dist/inspector/gui/CubeTextureElement.js',
  81. 'dist/inspector/adapters/Adapter.js',
  82. 'dist/inspector/tabs/Tab.js',
  83. 'dist/inspector/tabs/PropertyTab.js',
  84. 'dist/inspector/tools/AbstractTool.js',
  85. 'dist/inspector/treeTools/AbstractTreeTool.js',
  86. 'dist/inspector/**/*.js']
  87. }
  88. }
  89. },
  90. //Server creation
  91. connect: {
  92. server: {
  93. options: {
  94. port: 3000,
  95. base: '.'
  96. }
  97. },
  98. test: {
  99. options: {
  100. port: 3000,
  101. base: '.',
  102. keepalive:true
  103. }
  104. }
  105. },
  106. // Open default browser
  107. open: {
  108. local: {
  109. path: 'http://localhost:3000/dist/test'
  110. }
  111. },
  112. webpack: {
  113. inspector: require("./webpack.config.js")
  114. }
  115. });
  116. grunt.registerTask('default', 'Compile and watch source files', [
  117. 'dev',
  118. 'connect:server',
  119. 'open',
  120. 'watch'
  121. ]);
  122. grunt.registerTask('dev', 'build dev version', [
  123. 'clean:init',
  124. 'ts',
  125. 'sass',
  126. 'postcss',
  127. ]);
  128. grunt.registerTask('test', 'test dist version', [
  129. 'open',
  130. 'connect:test'
  131. ]);
  132. // Compilation and webpack
  133. grunt.registerTask('dist', 'build dist version', [
  134. 'dev',
  135. 'uglify',
  136. 'concat',
  137. 'webpack',
  138. 'clean:compilation'
  139. ]);
  140. };