This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
138 lines (127 loc) · 3.32 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*jshint camelcase: false*/
var path = require('path');
function userDir(dir) {
var homepath = process.env[/^win/.test(process.platform) ? 'USERPROFILE' : 'HOME'];
return path.resolve(homepath, dir);
}
function buildDir(subdir) {
return userDir(path.join('build', 'journalite', subdir));
}
module.exports = function (grunt) {
'use strict';
// load all grunt tasks
grunt.loadNpmTasks('grunt-node-webkit-builder');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-text-replace');
grunt.initConfig({
// configurable paths
config: {
app: 'app',
dist: buildDir('dist'),
wininst: 'wininst',
tmp: '.tmp'
},
shell: {
makensis: {
options: { stdout: true, failOnError: true },
command: 'makensis -DINSTALLERDIR=<%= config.dist %>/releases/Journalite/win -DFILESDIR=<%= config.dist %>/releases/Journalite/win/Journalite <%= config.wininst %>/script.nsi '
}
},
clean: {
tmp: {
files: [{
dot: true,
src: [
'<%= config.tmp %>/*',
'.tmp/*'
]
}]
}
},
useminPrepare: {
options: {
dest: '<%= config.tmp %>/app'
},
html: '<%= config.app %>/index.html'
},
usemin: {
options: {
dirs: ['<%= config.tmp %>/app']
},
html: ['<%= config.tmp %>/app/index.html'],
css: ['<%= config.tmp %>/app/css/{,*/}*.css']
},
cssmin: {
//TODO
},
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
dest: '<%= config.tmp %>/app',
src: [
'*.{ico,png,json,html}',
'img/{,*/}*.{webp,gif,svg,jpg,jpeg,png}',
'fonts/{,*/}*.*',
'templates/{,*/}*.*',
'node_modules/{,*/}*.*',
]
}]
},
credits: {
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
dest: '<%= config.dist %>/releases/Journalite/win/Journalite/',
src: [
'credits-app.txt',
]
}]
}
},
replace: {
dist: {
src: ['<%= config.app %>/package.json'],
dest: '<%= config.tmp %>/app/package.json',
replacements: [{
from: '"toolbar": true',
to: '"toolbar": false'
}]
}
},
nodewebkit: {
options: {
app_name: "Journalite",
build_dir: '<%= config.dist %>', // Where the build version of my node-webkit app is saved
version: '0.8.5',
credits: true,
mac: false,
win: true,
linux32: false,
linux64: true
},
src: ['<%= config.tmp %>/app/**/*'] // Your node-wekit app
}
});
grunt.registerTask('build', [
'clean:tmp',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'copy:dist',
'replace',
'usemin'
]);
grunt.registerTask('makeapp', ['build', 'nodewebkit', 'copy:credits']);
grunt.registerTask('makeinst', ['makeapp', 'shell:makensis']);
};