fixed grunt dev so pushstate routes now work ( 404 -> index.html)
This commit is contained in:
@@ -15,15 +15,24 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
files: ['build/ribica.bundle.js', 'app/css/*.css'],
|
files: ['build/ribica.bundle.js', 'app/css/*.css'],
|
||||||
tasks: ['config-dev', 'concat:css', 'concat:js']
|
tasks: ['config-dev', 'concat:css', 'concat:js']
|
||||||
},
|
},
|
||||||
connect: {
|
connect: {
|
||||||
server: {
|
server: {
|
||||||
options: {
|
options: {
|
||||||
port: 3001,
|
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: {
|
config: {
|
||||||
dev: {
|
dev: {
|
||||||
options: {
|
options: {
|
||||||
variables: {
|
variables: {
|
||||||
apiEndpoint: 'http://localhost:4567'
|
apiEndpoint: 'http://localhost:4567'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
prod: {
|
prod: {
|
||||||
options: {
|
options: {
|
||||||
variables: {
|
variables: {
|
||||||
apiEndpoint: '/api'
|
apiEndpoint: '/api'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replace: {
|
replace: {
|
||||||
dist: {
|
dist: {
|
||||||
options: {
|
options: {
|
||||||
variables: {
|
variables: {
|
||||||
'apiEndpoint': '<%= grunt.config.get("apiEndpoint") %>'
|
'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: {
|
concat: {
|
||||||
css: {
|
css: {
|
||||||
src: [
|
src: [
|
||||||
'node_modules/bootstrap/dist/css/bootstrap.min.css',
|
'node_modules/bootstrap/dist/css/bootstrap.min.css',
|
||||||
'app/css/*.css'
|
'app/css/*.css'
|
||||||
|
|
||||||
],
|
],
|
||||||
dest: 'build/ribica.css'
|
dest: 'build/ribica.css'
|
||||||
@@ -92,7 +104,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.registerTask('default', []);
|
grunt.registerTask('default', []);
|
||||||
grunt.registerTask('config-dev', ['config:dev', 'replace']);
|
grunt.registerTask('config-dev', ['config:dev', 'replace']);
|
||||||
grunt.registerTask('config-prod', ['config:prod', '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']);
|
grunt.registerTask('build', ['browserify', 'config-prod', 'concat:css', 'concat:js']);
|
||||||
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user