Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Warning: root path must be a string Use --force to continue.
- /* global module, conf */
- var modRewrite = require('connect-modrewrite');
- var mountFolder = function(connect, dir) {
- return connect.static(require('path').resolve(dir));
- };
- module.exports = function(grunt) {
- grunt.initConfig({
- copy: {
- base: {
- files: [
- {src: "index.html", dest: "BUILD/index.html"},
- {expand: true, src: "app/**", dest: "BUILD/"},
- {expand: true, src: "assets/**", dest: "BUILD/"}
- ]
- }
- },
- connect: {
- proxies: [
- {
- context: "/wwff",
- host: "localhost",
- port: "8080"
- }
- ],
- /**
- * Task defines a server at 9000,
- * watching the BUILD directory
- */
- dev: {
- options: {
- port: "9000",
- hostname: '*',
- base: "BUILD",
- middleware: function(connect, options) {
- var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
- return [
- // include the proxy first
- proxySnippet,
- modRewrite([
- '!\.html|\.js|\.swf|\.json|\.xml|\.css|\.png|\.jpg|\.gif|\.ico|\.aff|\.msi|\.zip|\.dic$ /index.html [L]'
- ]),
- // serve static files
- connect.static(options.base),
- // make empty directories browsable
- connect.directory(options.base)
- ];
- }
- }
- }
- },
- /*
- * This task watches the application and asset directories and
- * deploys any changes to the dev server
- */
- watch: {
- static: {
- files: [ "app/**/*.js", "app/**/*.html"],
- tasks: ["build"]
- }
- },
- clean: {
- build: ["BUILD/"],
- temp: ["tmp"]
- }
- });
- grunt.loadNpmTasks('grunt-contrib-copy');
- grunt.loadNpmTasks('grunt-contrib-connect');
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-connect-proxy');
- grunt.loadNpmTasks('grunt-contrib-clean');
- /*
- * Main BUILD Task
- */
- grunt.registerTask("build", "Copies app and asset files to the BUILD directory.", function() {
- grunt.task.run("copy:base");
- });
- grunt.registerTask("server", "Stand up a node server for development.", function() {
- grunt.task.run(["build", "configureProxies:dev", "connect:dev", "watch"]);
- });
- grunt.event.on('watch', function(action, filepath, target) {
- grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
- });
- };
- Verifying property connect.dev exists in config...OK
- File: [no files]
- Options: protocol="http", port="9000", hostname="*", base="BUILD", directory=null, keepalive=false, debug=false, livereload=false, open=false, useAvailablePort=false, onCreateServer=null, middleware=undefined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement