Skip to content

Commit 73cc0d7

Browse files
author
Matt Karl
committed
Updated to latest project-grunt
1 parent 2f4ac8b commit 73cc0d7

File tree

8 files changed

+18
-154
lines changed

8 files changed

+18
-154
lines changed

Gruntfile.js

Lines changed: 1 addition & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,9 @@
11
module.exports = function(grunt)
22
{
3-
var path = require('path'),
4-
_ = require('lodash');
5-
6-
// Combine the game builder and current project
7-
// configs into one object
8-
var config = require('project-grunt')(grunt, {
9-
autoInit: false,
3+
require('project-grunt')(grunt, {
104
data: {
115
buildDir : './build',
126
installerDir : './installer',
137
}
148
});
15-
16-
// Add the modules to config
17-
var build = grunt.file.readJSON('build.json');
18-
19-
// Filter an array of files and only return the javascript files
20-
var isJS = function(file){ return /\.js$/.test(file); };
21-
22-
// Filter an array of files and only return CSS and LESS files
23-
var isCSS = function(file){ return /\.(less|css)$/.test(file); };
24-
25-
var moduleTasks = [];
26-
var moduleTasksDebug = [];
27-
28-
// Loop through the modules and add each one
29-
// to the existing list of tasks, this is more
30-
// maintainable if done dynamically
31-
_.each(build.modules, function(files, name){
32-
33-
var js = _.filter(files, isJS);
34-
var css = _.filter(files, isCSS);
35-
var clean = [];
36-
var output;
37-
38-
moduleTasks.push('clean:'+name);
39-
moduleTasksDebug.push('clean:'+name);
40-
41-
if (js)
42-
{
43-
output = {};
44-
output['<%= jsFolder %>/'+name+'.js'] = js;
45-
46-
// Add the build
47-
config.uglify[name] = {
48-
files: output,
49-
options: '<%= uglify.app.options %>'
50-
};
51-
52-
// The replacements for web
53-
config.replace[name] = {
54-
src: '<%= jsFolder %>/'+name+'.js',
55-
overwrite: true,
56-
replacements: '<%= replace.main.replacements %>'
57-
};
58-
59-
// The replacements for app
60-
config.replace[name+'App'] = {
61-
src: '<%= jsFolder %>/'+name+'.js',
62-
overwrite: true,
63-
replacements: '<%= replace.app.replacements %>'
64-
};
65-
66-
// Add to hinting
67-
config.jshint.main.push(js);
68-
69-
// Add to source maps
70-
config.concat[name] = {
71-
src: js,
72-
dest: '<%= jsFolder %>/'+name+'.js'
73-
};
74-
75-
// add files to clean
76-
clean.push(
77-
'<%= jsFolder %>/'+name+'.js.map',
78-
'<%= jsFolder %>/'+name+'.js'
79-
);
80-
81-
config.watch.main.files.push(js);
82-
config.watch.main.tasks.push(
83-
'concat:'+name,
84-
'replace:'+name
85-
);
86-
87-
moduleTasks.push('uglify:'+name);
88-
moduleTasksDebug.push(
89-
'concat:'+name,
90-
'replace:'+name+'App'
91-
);
92-
}
93-
94-
if (css)
95-
{
96-
output = {};
97-
output['<%= cssFolder %>/'+name+'.css'] = css;
98-
99-
// Add the Less building
100-
config.less[name]= {
101-
files: output,
102-
options: '<%= less.release.options %>'
103-
};
104-
105-
// Add LESS debug building
106-
config.less[name+'Debug'] = {
107-
files: '<%= less.'+name+'.files %>',
108-
options: {
109-
sourceMap: true,
110-
sourceMapFilename: '<%= cssFolder %>/'+name+'.css.map',
111-
sourceMapURL: name + '.css.map',
112-
sourceMapBasepath: '<%= cssFolder %>'
113-
}
114-
};
115-
116-
// Add the watch css task
117-
config.watch.css.tasks.push('less:'+name+'Debug');
118-
119-
// Add files to clean
120-
clean.push(
121-
'<%= cssFolder %>/'+name+'.css.map',
122-
'<%= cssFolder %>/'+name+'.css'
123-
);
124-
125-
moduleTasks.push('less:'+name);
126-
moduleTasksDebug.push('less:'+name+'Debug');
127-
}
128-
129-
// Clean options
130-
config.clean[name] = clean;
131-
});
132-
133-
// Add the dynamic list of tasks
134-
grunt.registerTask('moduleTasks', moduleTasks);
135-
grunt.registerTask('moduleTasksDebug', moduleTasksDebug);
136-
137-
// Finally add the config
138-
grunt.initConfig(config);
1399
};

package.json

100755100644
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "SpringRollStudio",
3-
"private": true,
4-
"version": "0.1.2",
5-
"dependencies": {
6-
"grunt": "~0.4.5",
7-
"grunt-exec": "~0.4.6",
8-
"project-grunt": "~0.5.0",
9-
"grunt-node-webkit-builder": "~0.2.2",
10-
"lodash": "~2.4.1"
11-
}
12-
}
2+
"name": "SpringRollStudio",
3+
"private": true,
4+
"version": "0.1.2",
5+
"dependencies": {
6+
"grunt": "~0.4.5",
7+
"grunt-exec": "~0.4.6",
8+
"grunt-node-webkit-builder": "^0.2.2",
9+
"lodash": "~3.0.0",
10+
"project-grunt": "*"
11+
}
12+
}
File renamed without changes.

tasks/exec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module.exports = {
99
cmd: 'makensis <%= installerDir %>/win.nsi'
1010
},
1111
createOSXInstall: {
12-
cmd: 'appdmg <%= installerDir %>/osx.json <%= buildDir %>/<%= build.name %>-Setup.dmg'
12+
cmd: 'appdmg <%= installerDir %>/osx.json <%= buildDir %>/<%= project.name %>-Setup.dmg'
1313
},
1414
openOSXApp : {
15-
cmd: 'open <%= buildDir %>/<%= build.name %>/osx/<%= build.name %>.app'
15+
cmd: 'open <%= buildDir %>/<%= project.name %>/osx/<%= project.name %>.app'
1616
}
1717
};

tasks/overrides/clean.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
installers: ['<%= buildDir %>/<%= build.name %>-Setup.*']
2+
installers: ['<%= buildDir %>/<%= project.name %>-Setup.*']
33
};

tasks/overrides/jshint.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

tasks/overrides/uglify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
main: {
33
files: {
4-
'<%= jsFolder %>/main.js': '<%= build.js.main %>'
4+
'<%= jsFolder %>/main.js': '<%= project.js.main %>'
55
},
66
options: {
77
compress: {

tasks/overrides/watch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
22
css: {
33
files: [
4-
'<%= build.css.main %>',
5-
'<%= build.file %>',
4+
'<%= project.css.main %>',
5+
'<%= project.file %>',
66
'src/**/*.less'
77
],
88
tasks: [

0 commit comments

Comments
 (0)