Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.95 KB | None | 0 0
  1. // Generated on 2014-06-02 using generator-angular 0.8.0
  2. 'use strict';
  3.  
  4. // # Globbing
  5. // for performance reasons we're only matching one level down:
  6. // 'test/spec/{,*/}*.js'
  7. // use this if you want to recursively match all subfolders:
  8. // 'test/spec/**/*.js'
  9.  
  10. module.exports = function (grunt) {
  11.  
  12. // Load grunt tasks automatically
  13. require('load-grunt-tasks')(grunt);
  14.  
  15. // Time how long tasks take. Can help when optimizing build times
  16. require('time-grunt')(grunt);
  17.  
  18. // Define the configuration for all the tasks
  19. grunt.initConfig({
  20.  
  21. // Project settings
  22. yeoman: {
  23. // configurable paths
  24. app: require('./bower.json').appPath || 'app',
  25. dist: 'dist'
  26. },
  27.  
  28. // Watches files for changes and runs tasks based on the changed files
  29. watch: {
  30. bower: {
  31. files: ['bower.json'],
  32. tasks: ['bowerInstall']
  33. },
  34. js: {
  35. files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
  36. tasks: ['newer:jshint:all'],
  37. options: {
  38. livereload: true
  39. }
  40. },
  41. jsTest: {
  42. files: ['test/spec/{,*/}*.js'],
  43. tasks: ['newer:jshint:test', 'karma']
  44. },
  45. styles: {
  46. files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
  47. tasks: ['newer:copy:styles', 'autoprefixer']
  48. },
  49. less: {
  50. files: ['<%= yeoman.app %>/assets/less/*.less'],
  51. tasks: ['less:server']
  52. },
  53. gruntfile: {
  54. files: ['Gruntfile.js']
  55. },
  56. livereload: {
  57. options: {
  58. livereload: '<%= connect.options.livereload %>'
  59. },
  60. files: [
  61. '<%= yeoman.app %>/{,*/}*.html',
  62. '.tmp/assets/{,*/}*.css',
  63. '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  64. ]
  65. }
  66. },
  67.  
  68. // The actual grunt server settings
  69. connect: {
  70. options: {
  71. port: 9000,
  72. // Change this to '0.0.0.0' to access the server from outside.
  73. hostname: 'localhost',
  74. livereload: 35729
  75. },
  76. // courtesy of Phubase Tiewthanom
  77. livereload: {
  78. options: {
  79. middleware: function (connect) {
  80. return [
  81. connect.static('.tmp'),
  82. connect().use(
  83. '/bower_components',
  84. connect.static('./bower_components')
  85. ),
  86. connect.static(require('./bower.json').appPath || 'app')
  87. ];
  88. }
  89. }
  90. },
  91. test: {
  92. options: {
  93. port: 9001,
  94. base: [
  95. '.tmp',
  96. 'test',
  97. '<%= yeoman.app %>'
  98. ]
  99. }
  100. },
  101. dist: {
  102. options: {
  103. base: '<%= yeoman.dist %>'
  104. }
  105. }
  106. },
  107.  
  108. // Make sure code styles are up to par and there are no obvious mistakes
  109. jshint: {
  110. options: {
  111. jshintrc: '.jshintrc',
  112. reporter: require('jshint-stylish')
  113. },
  114. all: [
  115. 'Gruntfile.js',
  116. '<%= yeoman.app %>/scripts/**/*.js'
  117. ],
  118. test: {
  119. options: {
  120. jshintrc: 'test/.jshintrc'
  121. },
  122. src: ['test/spec/{,*/}*.js']
  123. }
  124. },
  125.  
  126. // Empties folders to start fresh
  127. clean: {
  128. dist: {
  129. files: [{
  130. dot: true,
  131. src: [
  132. '.tmp',
  133. '<%= yeoman.dist %>/*',
  134. '!<%= yeoman.dist %>/.git*'
  135. ]
  136. }]
  137. },
  138. server: '.tmp'
  139. },
  140.  
  141. // Add vendor prefixed styles
  142. autoprefixer: {
  143. options: {
  144. browsers: ['last 1 version']
  145. },
  146. dist: {
  147. files: [{
  148. expand: true,
  149. cwd: '.tmp/assets/css/',
  150. src: '{,*/}*.css',
  151. dest: '.tmp/assets/css/'
  152. }]
  153. }
  154. },
  155.  
  156. // Automatically inject Bower components into the app
  157. bowerInstall: {
  158. app: {
  159. src: ['<%= yeoman.app %>/index.html'],
  160. ignorePath: '<%= yeoman.app %>/',
  161. // we're not going to inject these as they're lazyloaded
  162. exclude: ['requirejs',
  163. 'mocha',
  164. 'jquery.vmap.europe.js',
  165. 'jquery.vmap.usa.js',
  166. 'Chart.min.js',
  167. 'raphael',
  168. 'morris',
  169. 'jquery.inputmask',
  170. 'jquery.validate.js',
  171. 'jquery.stepy.js',
  172. 'fullcalendar.js'
  173. ]
  174. }
  175. },
  176.  
  177. // Renames files for browser caching purposes
  178. rev: {
  179. dist: {
  180. files: {
  181. src: [
  182. '<%= yeoman.dist %>/scripts/{,*/}*.js',
  183. '<%= yeoman.dist %>/assets/css/{,*/}*.css',
  184. '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
  185. '<%= yeoman.dist %>/styles/fonts/*'
  186. ]
  187. }
  188. }
  189. },
  190.  
  191. // Reads HTML for usemin blocks to enable smart builds that automatically
  192. // concat, minify and revision files. Creates configurations in memory so
  193. // additional tasks can operate on them
  194. useminPrepare: {
  195. html: '<%= yeoman.app %>/index.html',
  196. options: {
  197. dest: '<%= yeoman.dist %>',
  198. flow: {
  199. html: {
  200. steps: {
  201. js: ['concat', 'uglifyjs'],
  202. css: ['cssmin']
  203. },
  204. post: {}
  205. }
  206. }
  207. }
  208. },
  209.  
  210. // Performs rewrites based on rev and the useminPrepare configuration
  211. usemin: {
  212. html: ['<%= yeoman.dist %>/{,*/}*.html'],
  213. css: ['<%= yeoman.dist %>/assets/css/{,*/}*.css'],
  214. options: {
  215. assetsDirs: ['<%= yeoman.dist %>']
  216. }
  217. },
  218.  
  219. // The following *-min tasks produce minified files in the dist folder
  220. cssmin: {
  221. options: {
  222. // root: '<%= yeoman.app %>',
  223. relativeTo: '<%= yeoman.app %>',
  224. processImport: true,
  225. noAdvanced: true
  226. }
  227. },
  228.  
  229. imagemin: {
  230. dist: {
  231. files: [{
  232. expand: true,
  233. cwd: '<%= yeoman.app %>/images',
  234. src: '{,*/}*.{png,jpg,jpeg,gif}',
  235. dest: '<%= yeoman.dist %>/images'
  236. }]
  237. }
  238. },
  239.  
  240. svgmin: {
  241. dist: {
  242. files: [{
  243. expand: true,
  244. cwd: '<%= yeoman.app %>/images',
  245. src: '{,*/}*.svg',
  246. dest: '<%= yeoman.dist %>/images'
  247. }]
  248. }
  249. },
  250.  
  251. htmlmin: {
  252. dist: {
  253. options: {
  254. collapseWhitespace: true,
  255. collapseBooleanAttributes: true,
  256. removeCommentsFromCDATA: true,
  257. removeOptionalTags: true
  258. },
  259. files: [{
  260. expand: true,
  261. cwd: '<%= yeoman.dist %>',
  262. src: ['*.html', 'views/{,*/}*.html'],
  263. dest: '<%= yeoman.dist %>'
  264. }]
  265. }
  266. },
  267.  
  268. // ngmin tries to make the code safe for minification automatically by
  269. // using the Angular long form for dependency injection. It doesn't work on
  270. // things like resolve or inject so those have to be done manually.
  271. ngmin: {
  272. dist: {
  273. files: [{
  274. expand: true,
  275. cwd: '.tmp/concat/scripts',
  276. src: '*.js',
  277. dest: '.tmp/concat/scripts'
  278. }]
  279. }
  280. },
  281.  
  282. // Replace Google CDN references
  283. cdnify: {
  284. dist: {
  285. html: ['<%= yeoman.dist %>/*.html']
  286. }
  287. },
  288.  
  289. // Copies remaining files to places other tasks can use
  290. copy: {
  291. dist: {
  292. files: [{
  293. expand: true,
  294. dot: true,
  295. cwd: '<%= yeoman.app %>',
  296. dest: '<%= yeoman.dist %>',
  297. src: [
  298. '*.{ico,png,txt}',
  299. '.htaccess',
  300. '*.html',
  301. 'views/{,*/}*.html',
  302. 'images/{,*/}*.{webp}',
  303. 'assets/**',
  304. // these files are lazyloaded
  305. 'bower_components/jquery.inputmask/dist/jquery.inputmask.bundle.js',
  306. 'bower_components/jquery-validation/dist/jquery.validate.js',
  307. 'bower_components/jqvmap/jqvmap/maps/jquery.vmap.europe.js',
  308. 'bower_components/jqvmap/jqvmap/maps/jquery.vmap.usa.js',
  309. 'bower_components/stepy/lib/jquery.stepy.js',
  310. 'bower_components/Chart.js/Chart.min.js',
  311. 'bower_components/raphael/raphael.js',
  312. 'bower_components/morris.js/morris.js',
  313. 'bower_components/fullcalendar/fullcalendar.js'
  314. ]
  315. }, {
  316. expand: true,
  317. cwd: '.tmp/images',
  318. dest: '<%= yeoman.dist %>/images',
  319. src: ['generated/*']
  320. }, {
  321. expand: true,
  322. flatten: true,
  323. cwd: '<%= yeoman.app %>',
  324. dest: '<%= yeoman.dist %>/assets/fonts',
  325. src: ['bower_components/font-awesome/fonts/*']
  326. }]
  327. },
  328. fonts: {
  329. expand: true,
  330. flatten: true,
  331. cwd: '<%= yeoman.app %>',
  332. dest: '<%= yeoman.dist %>/assets/fonts',
  333. src: 'bower_components/font-awesome/fonts/*'
  334. },
  335. styles: {
  336. expand: true,
  337. cwd: '<%= yeoman.app %>/assets/css',
  338. dest: '.tmp/assets/css',
  339. src: '{,*/}*.css'
  340. }
  341. },
  342.  
  343. // Run some tasks in parallel to speed up the build process
  344. concurrent: {
  345. server: [
  346. 'copy:styles'
  347. ],
  348. test: [
  349. 'copy:styles'
  350. ],
  351. dist: [
  352. 'copy:styles',
  353. 'copy:dist',
  354. // 'imagemin',
  355. // 'svgmin'
  356. ]
  357. },
  358. ngtemplates: {
  359. app: {
  360. src: 'app/views/templates/**.html',
  361. dest: 'app/scripts/core/modules/templates.js',
  362. options: {
  363. url: function(url) { return url.replace('app/views/', ''); },
  364. bootstrap: function(module, script) {
  365. return '/* jshint ignore:start */\nangular.module(\'theme.core.templates\', []).run([\'$templateCache\', function ($templateCache) {\n'+script+'}])\n/* jshint ignore:end */';
  366. }
  367. },
  368. }
  369. },
  370.  
  371. less: {
  372. server: {
  373. options: {
  374. // strictMath: true,
  375. dumpLineNumbers: true,
  376. sourceMap: true,
  377. sourceMapRootpath: '',
  378. outputSourceFiles: true
  379. },
  380. files: [
  381. {
  382. expand: true,
  383. cwd: '<%= yeoman.app %>/assets/less',
  384. src: 'styles.less',
  385. dest: '.tmp/assets/css',
  386. ext: '.css'
  387. }
  388. ]
  389. },
  390. dist: {
  391. options: {
  392. cleancss: true,
  393. report: 'min'
  394. },
  395. files: [
  396. {
  397. expand: true,
  398. cwd: '<%= yeoman.app %>/assets/less',
  399. src: 'styles.less',
  400. dest: '.tmp/assets/css',
  401. ext: '.css'
  402. }
  403. ]
  404. }
  405. },
  406.  
  407. // By default, your `index.html`'s <!-- Usemin block --> will take care of
  408. // minification. These next options are pre-configured if you do not wish
  409. // to use the Usemin blocks.
  410. // cssmin: {
  411. // dist: {
  412. // files: {
  413. // '<%= yeoman.dist %>/styles/main.css': [
  414. // '.tmp/styles/{,*/}*.css',
  415. // '<%= yeoman.app %>/styles/{,*/}*.css'
  416. // ]
  417. // }
  418. // }
  419. // },
  420. // uglify: {
  421. // dist: {
  422. // files: {
  423. // '<%= yeoman.dist %>/scripts/scripts.js': [
  424. // '<%= yeoman.dist %>/scripts/scripts.js'
  425. // ]
  426. // }
  427. // }
  428. // },
  429. // concat: {
  430. // dist: {}
  431. // },
  432.  
  433. // Test settings
  434. karma: {
  435. unit: {
  436. configFile: 'karma.conf.js',
  437. singleRun: true
  438. }
  439. },
  440. processhtml: {
  441. options: {
  442. commentMarker: 'prochtml',
  443. process: true
  444. },
  445. dist: {
  446. files: {
  447. '<%= yeoman.dist %>/index.html': ['<%= yeoman.dist %>/index.html']
  448. }
  449. }
  450. },
  451. uglify: {
  452. options: {
  453. mangle: false
  454. }
  455. }
  456. });
  457.  
  458.  
  459. grunt.registerTask('serve', function (target) {
  460. if (target === 'dist') {
  461. return grunt.task.run(['build', 'connect:dist:keepalive']);
  462. }
  463.  
  464. grunt.task.run([
  465. 'clean:server',
  466. 'bowerInstall',
  467. 'concurrent:server',
  468. 'autoprefixer',
  469. 'connect:livereload',
  470. 'watch'
  471. ]);
  472. });
  473.  
  474. grunt.registerTask('server', function (target) {
  475. grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  476. grunt.task.run(['serve:' + target]);
  477. });
  478.  
  479. grunt.registerTask('test', [
  480. 'clean:server',
  481. 'concurrent:test',
  482. 'autoprefixer',
  483. 'connect:test',
  484. 'karma'
  485. ]);
  486.  
  487. grunt.registerTask('build', [
  488. 'clean:dist',
  489. 'bowerInstall',
  490. 'ngtemplates',
  491. 'useminPrepare',
  492. 'concurrent:dist',
  493. 'less:dist',
  494. 'autoprefixer',
  495. 'concat',
  496. // 'ngmin',
  497. 'copy:dist',
  498. // 'copy:fonts',
  499. // 'cdnify',
  500. 'cssmin',
  501. 'uglify',
  502. 'rev',
  503. 'usemin',
  504. 'processhtml:dist',
  505. // 'htmlmin'
  506. ]);
  507.  
  508. grunt.registerTask('default', [
  509. // 'newer:jshint',
  510. // 'test',
  511. 'build'
  512. ]);
  513. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement