grunt 命令在配置 EaselJS 项目时不运行服务器

grunt command does not run server while configuring EaselJS project

本文关键字:运行 服务器 项目 EaselJS 命令 配置 grunt      更新时间:2023-09-26

我在 EaselJS 中配置我的项目以进行游戏开发时遇到了一些问题。下面你可以看到我的Grunt.js文件。

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    browserify: {
        build: {
            files: {
                'build/scripts/app.bundle.js': ['app/lib/main.js']
            }
        }
    },
    copy: {
        scripts: {
            src: [
                'bower_components/easeljs/lib/easeljs-0.8.0.combined.js',
            ],
            dest: 'build/scripts/',
            expand: true,
            flatten: true
        },
        html: {
            src: [
                'app/index.html',
            ],
            dest: 'build/',
            expand: true,
            flatten: true
        }
    },
    connect: {
        server: {
            options: {
                port: 9001,
                base: 'build'
            }
        }
    },
    watch: {
        options: {
            livereload: true
        },
        scripts: {
            files: ['app/lib/**/*.js', 'app/*.html'],
            tasks: ['build']
        }
    }
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-browserify');
// Default task(s).
grunt.registerTask('build', ['browserify', 'copy']);
grunt.registerTask('default', ['build', 'connect', 'watch']);};

每当我在命令行上运行 grunt 命令时,Windows 都会询问"如何打开此文件?当我选择浏览器时,它只是打开并向我显示 Grunt.js 文件。

如果您能帮助我解决这个问题,我将不胜感激。谢谢

好吧,

我想通了。我将我的文件命名为Grunt.js而不是Gruntfile.js。我将其更改为Gruntfile.js,运行了grunt命令,它按预期工作。