2016-05-22 11 views
1

Aus irgendeinem Grund funktioniert grunt vom Terminal funktioniert nicht. Wenn ich laufen grunt dev und öffnen http://localhost:8000/ es funktioniert, aber wenn ich es sagt nur grunt verwenden This site can’t be reached. localhost refused to connect.Grunt diese Website kann nicht erreicht werden

Alle Ideen, was ich vermisst?

'use strict'; 
var path = require('path'); 
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet; 

var folderMount = function folderMount(connect, point) { 
    return connect.static(path.resolve(point)); 
}; 

module.exports = function (grunt) { 
    grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 

    clean: { 
     build: { 
     src: [".sass-cache"] 
     } 
    }, // end clean 

    sass: { 
     dist: { 
     options: { 
      style: 'expanded', 
      noCache: true 
     }, 
     files: { 
      'app/production/css/style.css': 'app/scss/style.scss' 
     } 
     } 
    }, // end sass 

    cssmin: { 
     target: { 
     files: [{ 
      expand: true, 
      cwd: 'app/production/css', 
      src: ['*.css', '!*.min.css'], 
      dest: 'app/production/css', 
      ext: '.min.css' 
     }] 
     } 
    }, //end cssmin 

    connect: { 
     server: { 
     options: { 
      port: 8000 
     } 
     } 
    }, // end connect 

    uglify: { 
     options: { 
     mangle: false 
     }, 
     my_target: { 
     files: { 
      'app/production/js/app.min.js': ['app/js/module.js', 'app/js/config.js', 'app/js/factory.js', 'app/js/filter.js', 'app/js/PotatoAppController.js'] 
     } 
     } 
    }, // end js minify 

    watch: { // this is a watcher, to run this in terminal write: grunt watch 
     options: { 
     dateFormat: function(time) { 
      grunt.log.writeln('The watch finished in ' + time + 'ms at' + (new Date()).toString()); 
      grunt.log.writeln('Waiting for new changes ...'); 
     }, 
     livereload: true 
     }, 

     css: { 
     files: 'app/scss/style.scss', 
     tasks: ['sass', 'cssmin'] 
     }, 

     jsmin: { 
     files: 'app/js/*.js', 
     tasks: ['uglify'] 
     }, 

     html: { 
      files: ['app/views/**/*.html'], 
      options: { 
       livereload: true 
      } 
     } 
    } // end watch 
    }); 

    grunt.loadNpmTasks('grunt-contrib-watch'); // Load the plugin that provides the "watch" task. 
    grunt.loadNpmTasks('grunt-contrib-cssmin'); // Load the plugin that provides the "cssmin" task. 
    grunt.loadNpmTasks('grunt-contrib-sass'); // Load the plugin that provides the "sass" task. 
    grunt.loadNpmTasks('grunt-contrib-uglify'); // Load the plugin that provides the "uglify" task. 
    grunt.loadNpmTasks('grunt-contrib-livereload'); // Load the plugin that provides the "livereload" task. 
    grunt.loadNpmTasks('grunt-contrib-connect'); // Load the plugin that provides the "connect" task. 
    grunt.loadNpmTasks('grunt-contrib-clean'); // Load the plugin that provides the "clean" task. 

    grunt.registerTask('default', ['watch']); // this is the default command, use in terminal 'grunt' 
    grunt.registerTask('dev', ['connect', 'sass', 'cssmin', 'uglify', 'clean', 'watch']); // use 'grunt dev' for development 
}; 

Antwort

0

Sobald Sie 'grunt' ausführen, wird der 'default' Befehl ausgeführt.

In Ihrem Fall wird nur 'Watch' Task ausgeführt.

grunt.registerTask('default', ['watch']); 

Wenn Sie "localhost" erreichen möchten, müssen Sie das Modul "connect" ausführen. "Watch" Aufgabe ist nur beobachtete Dateiänderungen. Web-Server nicht starten.

'connect' dient zum Starten des Webservers.

Danke.

Verwandte Themen