fixed grunt dev so pushstate routes now work ( 404 -> index.html)

This commit is contained in:
Senad Uka
2015-02-22 13:28:21 +01:00
parent 2b6d93a437
commit 3af52737d4

View File

@@ -15,15 +15,24 @@ module.exports = function(grunt) {
}
},
watch: {
files: ['build/ribica.bundle.js', 'app/css/*.css'],
tasks: ['config-dev', 'concat:css', 'concat:js']
watch: {
files: ['build/ribica.bundle.js', 'app/css/*.css'],
tasks: ['config-dev', 'concat:css', 'concat:js']
},
connect: {
server: {
options: {
port: 3001,
base: 'build'
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));
}
];
},
}
}
},
@@ -35,39 +44,42 @@ module.exports = function(grunt) {
}
},
config: {
dev: {
options: {
variables: {
apiEndpoint: 'http://localhost:4567'
}
}
},
prod: {
options: {
variables: {
apiEndpoint: '/api'
}
}
}
dev: {
options: {
variables: {
apiEndpoint: 'http://localhost:4567'
}
}
},
prod: {
options: {
variables: {
apiEndpoint: '/api'
}
}
}
},
replace: {
dist: {
options: {
variables: {
'apiEndpoint': '<%= grunt.config.get("apiEndpoint") %>'
dist: {
options: {
variables: {
'apiEndpoint': '<%= grunt.config.get("apiEndpoint") %>'
},
force: true
},
files: [{
expand: true,
flatten: true,
src: ['build/ribica.bundle.js'],
dest: 'build/'
}]
}
},
force: true
},
files: [
{expand: true, flatten: true, src: ['build/ribica.bundle.js'], dest: 'build/'}
]
}
},
concat: {
css: {
src: [
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'app/css/*.css'
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'app/css/*.css'
],
dest: 'build/ribica.css'
@@ -87,12 +99,12 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-config');
grunt.loadNpmTasks('grunt-replace');
grunt.registerTask('default', []);
grunt.registerTask('config-dev', ['config:dev', 'replace']);
grunt.registerTask('config-prod', ['config:prod', 'replace']);
grunt.registerTask('dev', ['browserify', 'config-dev','concat:css', 'concat:js', 'connect:server:keepalive']);
grunt.registerTask('dev', ['browserify', 'config-dev', 'concat:css', 'concat:js', 'connect:server:keepalive']);
grunt.registerTask('build', ['browserify', 'config-prod', 'concat:css', 'concat:js']);
};
};