1 module.exports = function (grunt) {
3 grunt.loadNpmTasks('grunt-contrib-clean');
4 grunt.loadNpmTasks('grunt-contrib-uglify');
5 grunt.loadNpmTasks('grunt-contrib-copy');
6 grunt.loadNpmTasks('grunt-contrib-cssmin');
7 grunt.loadTasks('tools/grunt-tasks');
10 packageInfo: grunt.file.readJSON('package.json'),
14 // minify and concat JS
18 'build/app/js/main.js': ['app/js/main.js'],
19 'build/app/js/help.js': ['app/js/help.js'],
20 'build/app/js/license.js': ['app/js/license.js'],
21 'build/app/js/run.js': ['app/js/run.js']
26 // minify and concat CSS
30 'build/app/css/all.css': [
32 'app/css/license.css',
39 // copy assets and the index.html file to build/app/;
40 // NB we rewrite index.html during copy to point at the
41 // minified/concated js file all.js and minified/concated CSS file
46 { expand: true, cwd: '.', src: ['config.xml'], dest: 'build/app/' },
47 { expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/app/' },
48 { expand: true, cwd: '.', src: ['README.txt'], dest: 'build/app/' },
49 { expand: true, cwd: '.', src: ['app/**.html'], dest: 'build/' },
50 { expand: true, cwd: '.', src: ['app/audio/**'], dest: 'build/' },
51 { expand: true, cwd: '.', src: ['app/fonts/**'], dest: 'build/' },
52 { expand: true, cwd: '.', src: ['app/images/**'], dest: 'build/' },
53 { expand: true, cwd: '.', src: ['app/lib/**'], dest: 'build/' },
54 { expand: true, cwd: '.', src: ['app/_locales/**'], dest: 'build/' }
57 // this rewrites the <script> tag in the index.html file
58 // to point at the minified/concated js file all.js;
59 // and the stylesheet tags to point at all.css;
60 // it additionally strips out as much space and as many newlines
61 // as possible from HTML files (NB this may be dangerous if
62 // files are space-sensitive, but most HTML shouldn't be)
63 processContent: function (content) {
64 if (content.match(/DOCTYPE/)) {
66 content = content.replace(/.+\/\/.+?\n/g, '');
67 content = content.replace(/<!--[\s\S]+?-->/g, '');
70 content = content.replace(/main\.css/, '!!!all.css!!!');
71 content = content.replace(/<link rel="stylesheet" href="[^\!]+?">\n/g, '');
74 content = content.replace(/!!!/g, '');
76 // whitespace reduction
77 content = content.replace(/[ ]{2,}/g, ' ');
78 content = content.replace(/\n{2,}/g, '\n');
84 // if you have other resources which you don't want to have
85 // treated as text, add them here
86 processContentExclude: [
99 // make wgt package in build/ directory
101 appName: '<%= packageInfo.name %>',
102 version: '<%= packageInfo.version %>',
103 files: 'build/app/**',
104 stripPrefix: 'build/app/',
107 addGitCommitId: false
113 localFiles: './tools/grunt-tasks/tizen-app.sh',
114 remoteDestDir: '/opt/home/developer/',
122 pattern: 'build/*.wgt',
125 remoteDestDir: '/opt/home/developer/'
130 remoteScript: '/opt/home/developer/tizen-app.sh'
135 remoteScript: '/opt/home/developer/tizen-app.sh'
141 pattern: '/opt/home/developer/*.wgt',
144 remoteScript: '/opt/home/developer/tizen-app.sh'
149 remoteScript: '/opt/home/developer/tizen-app.sh',
151 openBrowser: 'google-chrome %URL%'
156 remoteScript: '/opt/home/developer/tizen-app.sh'
161 grunt.registerTask('dist', ['clean', 'cssmin:dist', 'uglify:dist', 'copy:dist']);
163 grunt.registerTask('pkg', 'Create package; call with pkg:STR to append STR to package name', function (identifier) {
164 grunt.task.run('dist');
166 var packageTask = (identifier ? 'package:' + identifier : 'package');
167 grunt.task.run(packageTask);
170 grunt.registerTask('reinstall', ['pkg', 'sdb:prepare', 'sdb:pushwgt', 'sdb:stop', 'sdb:uninstall', 'sdb:install', 'sdb:debug']);
171 grunt.registerTask('install', ['pkg', 'sdb:prepare', 'sdb:pushwgt', 'sdb:install', 'sdb:debug']);
172 grunt.registerTask('restart', ['sdb:stop', 'sdb:start']);
173 grunt.registerTask('default', 'dist');