Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何定义GruntJS服务的内容?_Node.js_Angularjs_Npm_Gruntjs_Yeoman - Fatal编程技术网

Node.js 如何定义GruntJS服务的内容?

Node.js 如何定义GruntJS服务的内容?,node.js,angularjs,npm,gruntjs,yeoman,Node.js,Angularjs,Npm,Gruntjs,Yeoman,我正在关注新的谷歌开发者视频,但事情并不像它为艾迪做的那样有效 当我运行grunt服务器时,grunt会在http://localhost:9000/。为什么不像加载Addy那样加载/mytodo/dist/views/main.html或/mytodo/app/views/main.html 这是我的/mytodo/grunfile.js代码: 'use strict'; var lrSnippet = require('grunt-contrib-livereload/lib/utils')

我正在关注新的谷歌开发者视频,但事情并不像它为艾迪做的那样有效

当我运行
grunt服务器时,
grunt会在
http://localhost:9000/
。为什么不像加载Addy那样加载
/mytodo/dist/views/main.html
/mytodo/app/views/main.html

这是我的
/mytodo/grunfile.js
代码:

'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var yeomanConfig = {
    app: 'app',
    dist: 'dist'
  };

  try {
    yeomanConfig.app = require('./component.json').appPath || yeomanConfig.app;
  } catch (e) {}

  grunt.initConfig({
    yeoman: yeomanConfig,
    watch: {
      coffee: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
        tasks: ['coffee:dist']
      },
      coffeeTest: {
        files: ['test/spec/{,*/}*.coffee'],
        tasks: ['coffee:test']
      },
      compass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        tasks: ['compass']
      },
      livereload: {
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ],
        tasks: ['livereload']
      }
    },
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, '.tmp'),
              mountFolder(connect, yeomanConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, '.tmp'),
              mountFolder(connect, 'test')
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ]
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },
    coffee: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts',
          src: '{,*/}*.coffee',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        imagesDir: '<%= yeoman.app %>/images',
        javascriptsDir: '<%= yeoman.app %>/scripts',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: '<%= yeoman.app %>/components',
        relativeAssets: true
      },
      dist: {},
      server: {
        options: {
          debugInfo: true
        }
      }
    },
    concat: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': [
            '.tmp/scripts/{,*/}*.js',
            '<%= yeoman.app %>/scripts/{,*/}*.js'
          ]
        }
      }
    },
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        dirs: ['<%= yeoman.dist %>']
      }
    },
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    cssmin: {
      dist: {
        files: {
          '<%= yeoman.dist %>/styles/main.css': [
            '.tmp/styles/{,*/}*.css',
            '<%= yeoman.app %>/styles/{,*/}*.css'
          ]
        }
      }
    },
    htmlmin: {
      dist: {
        options: {
          /*removeCommentsFromCDATA: true,
          // https://github.com/yeoman/grunt-usemin/issues/44
          //collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: true,
          useShortDoctype: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true*/
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>',
          src: ['*.html', 'views/*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/scripts',
          src: '*.js',
          dest: '<%= yeoman.dist %>/scripts'
        }]
      }
    },
    uglify: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': [
            '<%= yeoman.dist %>/scripts/scripts.js'
          ]
        }
      }
    },
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,txt}',
            '.htaccess',
            'components/**/*',
            'images/{,*/}*.{gif,webp}',
            'styles/fonts/*'
          ]
        }]
      }
    }
  });

  grunt.renameTask('regarde', 'watch');

  grunt.registerTask('server', [
    'clean:server',
    'coffee:dist',
    'compass:server',
    'livereload-start',
    'connect:livereload',
    'open',
    'watch'
  ]);

  grunt.registerTask('test', [
    'clean:server',
    'coffee',
    'compass',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'jshint',
    'test',
    'coffee',
    'compass:dist',
    'useminPrepare',
    'imagemin',
    'cssmin',
    'htmlmin',
    'concat',
    'copy',
    'cdnify',
    'ngmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('default', ['build']);
};
“严格使用”;
var lrnippet=require('grunt-contrib-livereload/lib/utils')。livereloadSnippet;
var mountFolder=函数(连接,目录){
返回connect.static(require('path').resolve(dir));
};
module.exports=函数(grunt){
//加载所有grunt任务
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
//可配置路径
var yeomanConfig={
应用程序:“应用程序”,
dist:“dist”
};
试一试{
yeomanConfig.app=require('./component.json').appPath | | yeomanConfig.app;
}捕获(e){}
grunt.initConfig({
约曼:约曼图,
观察:{
咖啡:{
文件:['/scripts/{,*/}*.coffee'],
任务:['coffee:dist']
},
咖啡测试:{
文件:['test/spec/{,*/}*.coffee'],
任务:[“咖啡:测试”]
},
指南针:{
文件:['/styles/{,*/}*{scss,sass}'],
任务:[“指南针”]
},
利弗雷罗德:{
档案:[
'/{,*/}*.html',
“{.tmp,}/styles/{,*/}*.css”,
“{.tmp,}/scripts/{,*/}*.js”,
“/images/{,*/}*{png,jpg,jpeg,gif,webp,svg}”
],
任务:['livereload']
}
},
连接:{
选项:{
港口:9000,
//将此更改为“0.0.0.0”以从外部访问服务器。
主机名:“localhost”
},
利弗雷罗德:{
选项:{
中间件:功能(连接){
返回[
小片段,
mountFolder(连接“.tmp”),
mountFolder(连接,yeomanConfig.app)
];
}
}
},
测试:{
选项:{
中间件:功能(连接){
返回[
mountFolder(连接“.tmp”),
安装文件夹(连接“测试”)
];
}
}
}
},
开放式:{
服务器:{
网址:'http://localhost:'
}
},
清洁:{
地区:{
档案:[{
多特:没错,
src:[
“.tmp”,
'/*',
“!/.git*”
]
}]
},
服务器:'.tmp'
},
jshint:{
选项:{
jshintrc:“.jshintrc”
},
全部:[
“Gruntfile.js”,
“/scripts/{,*/}*.js”
]
},
业力:{
单位:{
configFile:'karma.conf.js',
singleRun:对
}
},
咖啡:{
地区:{
档案:[{
是的,
cwd:“/scripts”,
src:“{,*/}*.coffee”,
目标:'.tmp/scripts',
分机:'.js'
}]
},
测试:{
档案:[{
是的,
cwd:“测试/规范”,
src:“{,*/}*.coffee”,
目的地:'.tmp/spec',
分机:'.js'
}]
}
},
指南针:{
选项:{
sassDir:“/styles”,
cssDir:“.tmp/styles”,
imagesDir:“/images”,
javascriptsDir:“/scripts”,
fontsDir:“/styles/fonts”,
importPath:“/components”,
相对论:对
},
地区:{},
服务器:{
选项:{
debugInfo:true
}
}
},
康卡特:{
地区:{
档案:{
“/scripts/scripts.js”:[
'.tmp/scripts/{,*/}*.js',
“/scripts/{,*/}*.js”
]
}
}
},
使用准备:{
html:“/index.html”,
选项:{
目标:“”
}
},
usemin:{
html:['/{,*/}*.html'],
css:['/styles/{,*/}*.css'],
选项:{
目录:['']
}
},
imagemin:{
地区:{
档案:[{
是的,
cwd:“/images”,
src:“{,*/}*{png,jpg,jpeg}”,
目标:'/images'
}]
}
},
cssmin:{
地区:{
档案:{
“/styles/main.css”:[
“.tmp/styles/{,*/}*.css”,
“/styles/{,*/}*.css”
]
}
}
},
htmlmin:{
地区:{
选项:{
/*removeCommentsFromCDATA:true,
// https://github.com/yeoman/grunt-usemin/issues/44
//拼贴空白:对,
collapseBooleanAttributes:没错,
RemoveAttribute属性:对,
删除和声明:是的,
useShortDoctype:true,
RemovemptyAttributes:没错,
removeOptionalTags:true*/
},
档案:[{
是的,
cwd:“”,
src:['*.html','views/*.html'],
目标:“”
}]
}
},
cdnify:{
地区:{
html:['/*.html']
}
},
ngmin:{
地区:{
档案:[{
是的,
cwd:“/scripts”,
src:'*.js',
目标:'/scripts'
}]
}
},
丑陋的:{
地区:{
档案:{
“/scripts/scripts.js”:[
“/scripts/scripts.js”
]
}
}
},
修订版:{
地区:{
档案:{
src:[
“/scripts/{,*/}*.js”,
“/styles/{,*/}*.css”,
“/images/{,*/}*{png,jpg,jpeg,gif,webp,svg}”,
“/styles/fonts/*”
]
}
}
},
副本:{
地区:{
档案:[{
是的,
多特:没错,
cwd:“”,
目标:'',
src:[
“*.{ico,txt}”,
“.htaccess”,
“组件/***”,
'images/{,*/}*{gif,webp}',
“样式/字体/*”
]
}]
}
}
});
grunt.renameTask('regarde','watch');
grunt.registerTask(