Skip to content

Commit

Permalink
Fix Grunt & add grunt-connect-proxy2
Browse files Browse the repository at this point in the history
  • Loading branch information
chyuaner committed Jun 26, 2018
1 parent 7ccc29c commit a49c527
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -15,7 +15,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{dest/*,src/*}]
[{dist/*,src/*}]
# Change these settings to your own preference
indent_style = space
indent_size = 2
Expand Down
35 changes: 28 additions & 7 deletions Gruntfile.js
Expand Up @@ -34,12 +34,32 @@ module.exports = function(grunt) {
},

connect: {
server: {
options: {
hostname: '*',
base: 'dist'
}
}
server: {
options: {
hostname: 'localhost',
port: 8000,
base: 'dist',
middleware: function (connect, options, defaultMiddleware) {
var proxy = require('grunt-connect-proxy2/lib/utils').proxyRequest;
return [
// Include the proxy first
proxy
].concat(defaultMiddleware);
}
},
proxies: [
{
context: '/gsat/api',
host: 'predict.chu.edu.tw',
port: 80,
https: false,
changeOrigin: true,
rewrite: {
'^/gsat/api': '2018/gsat/api'
}
}
]
}
},

watch: {
Expand All @@ -60,6 +80,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-connect-proxy2');

grunt.registerTask('default', ['copy', 'sass', 'connect', 'watch']);
grunt.registerTask('default', ['copy', 'sass', 'configureProxies:server', 'connect:server', 'watch']);
}
279 changes: 279 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -12,6 +12,7 @@
"devDependencies": {
"bower": "^1.8.4",
"grunt": "^0.4.5",
"grunt-connect-proxy2": "^2.0.0",
"grunt-contrib-connect": "^0.10.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-watch": "^0.6.1",
Expand Down

0 comments on commit a49c527

Please sign in to comment.