2015-01-22 06:38:48 +01:00
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
grunt.initConfig({
|
|
|
|
|
browserify: {
|
|
|
|
|
basic: {
|
|
|
|
|
src: ['app/ribica.js'],
|
|
|
|
|
dest: 'build/ribica.bundle.js',
|
|
|
|
|
options: {
|
2015-05-27 11:31:03 +02:00
|
|
|
transform: ['reactify'],
|
2015-01-22 06:38:48 +01:00
|
|
|
browserifyOptions: {
|
|
|
|
|
standalone: 'RIBICA',
|
2015-05-27 11:31:03 +02:00
|
|
|
debug: true
|
2015-01-22 06:38:48 +01:00
|
|
|
},
|
|
|
|
|
watch: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-02-22 13:28:21 +01:00
|
|
|
watch: {
|
|
|
|
|
files: ['build/ribica.bundle.js', 'app/css/*.css'],
|
|
|
|
|
tasks: ['config-dev', 'concat:css', 'concat:js']
|
2015-01-22 06:38:48 +01:00
|
|
|
},
|
|
|
|
|
connect: {
|
|
|
|
|
server: {
|
|
|
|
|
options: {
|
|
|
|
|
port: 3001,
|
2015-06-02 12:30:48 +02:00
|
|
|
base: 'build',
|
|
|
|
|
middleware: function(connect, options) {
|
|
|
|
|
return [
|
|
|
|
|
function(req, res) {
|
|
|
|
|
var filename = 'build/' + req.url;
|
|
|
|
|
if ((filename === 'build//') || !grunt.file.exists(filename)) filename = 'build/index.html';
|
|
|
|
|
res.end(grunt.file.read(filename));
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
},
|
2015-01-22 06:38:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
uglify: {
|
|
|
|
|
my_target: {
|
|
|
|
|
files: {
|
|
|
|
|
'build/ribica.min.js': ['build/ribica.js']
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-02-16 21:36:14 +01:00
|
|
|
config: {
|
2015-02-22 13:28:21 +01:00
|
|
|
dev: {
|
|
|
|
|
options: {
|
|
|
|
|
variables: {
|
|
|
|
|
apiEndpoint: 'http://localhost:4567'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
prod: {
|
|
|
|
|
options: {
|
|
|
|
|
variables: {
|
|
|
|
|
apiEndpoint: '/api'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-16 21:36:14 +01:00
|
|
|
},
|
|
|
|
|
replace: {
|
2015-02-22 13:28:21 +01:00
|
|
|
dist: {
|
|
|
|
|
options: {
|
|
|
|
|
variables: {
|
|
|
|
|
'apiEndpoint': '<%= grunt.config.get("apiEndpoint") %>'
|
|
|
|
|
},
|
|
|
|
|
force: true
|
|
|
|
|
},
|
|
|
|
|
files: [{
|
|
|
|
|
expand: true,
|
|
|
|
|
flatten: true,
|
|
|
|
|
src: ['build/ribica.bundle.js'],
|
2015-06-14 05:28:28 +02:00
|
|
|
dest: 'build/configured'
|
2015-02-22 13:28:21 +01:00
|
|
|
}]
|
|
|
|
|
}
|
2015-02-16 21:36:14 +01:00
|
|
|
},
|
2015-01-22 06:38:48 +01:00
|
|
|
concat: {
|
|
|
|
|
css: {
|
|
|
|
|
src: [
|
2015-02-22 13:28:21 +01:00
|
|
|
'app/css/*.css'
|
2015-01-22 06:38:48 +01:00
|
|
|
|
|
|
|
|
],
|
|
|
|
|
dest: 'build/ribica.css'
|
|
|
|
|
},
|
|
|
|
|
js: {
|
2015-06-14 05:28:28 +02:00
|
|
|
src: ['build/configured/ribica.bundle.js'],
|
2015-01-22 06:38:48 +01:00
|
|
|
dest: 'build/ribica.js'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
|
grunt.loadNpmTasks('grunt-browserify');
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
2015-02-16 21:36:14 +01:00
|
|
|
grunt.loadNpmTasks('grunt-config');
|
|
|
|
|
grunt.loadNpmTasks('grunt-replace');
|
2015-02-22 13:28:21 +01:00
|
|
|
|
2015-01-22 06:38:48 +01:00
|
|
|
|
|
|
|
|
grunt.registerTask('default', []);
|
2015-02-16 21:36:14 +01:00
|
|
|
grunt.registerTask('config-dev', ['config:dev', 'replace']);
|
|
|
|
|
grunt.registerTask('config-prod', ['config:prod', 'replace']);
|
2015-02-22 13:28:21 +01:00
|
|
|
grunt.registerTask('dev', ['browserify', 'config-dev', 'concat:css', 'concat:js', 'connect:server:keepalive']);
|
2015-02-16 21:36:14 +01:00
|
|
|
grunt.registerTask('build', ['browserify', 'config-prod', 'concat:css', 'concat:js']);
|
|
|
|
|
|
2015-04-18 16:13:55 +02:00
|
|
|
};
|