Grunt索引文件未运行

时间:2016-04-19 17:55:03

标签: gruntjs watch

我正在尝试将我的index.html放在我的应用程序的根目录(app / index.html),并使用我继承的文件中的grunt运行。

我的grunt文件如下:

module.exports = function(grunt) {

// 1. All configuration goes here
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    sass_directory_import: {
        your_target: {
            files: {
                src: ['css/sass/parts/_all.scss']
            },
        },
    },
    connect: {
      server: {
        options: {
          port: 9000,
          hostname: 'localhost',
          base: ['./'],
          keepalive: true,
          open: {
          target: 'http://localhost:9000'
        }
        }
      }
    },
    sass: {
        dist: {
            options: {
                loadPath: require('node-bourbon').includePaths,
                sourceMap: true
            },
            files: {
                'css/style.css' : 'css/sass/style.scss',
                'css/style-ie.css' : 'css/sass/style-ie.scss'
            }
        },
    },
    watch: {

        sass: {
            files: 'css/sass/**/*.scss',
            tasks: ['sass_directory_import','sass']
        }
    }
});

// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-sass-directory-import');
grunt.loadNpmTasks('grunt-contrib-connect');

// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default',['watch', 'connect:server']);
grunt.registerTask('build',['sass', 'uglify']);

};

我希望索引显示在端口:http://localhost:9000下,但是当我运行默认的监视任务时,只会看到正在监视的sass文件的更改而没有其他内容。如何让grunt在给定端口下运行文件?我之前只使用过Gulp而且找不到很容易使用的咕噜声。是否有一个不必安装的grunt服务器/连接任务?

0 个答案:

没有答案