Search code examples
gruntjsmelonjs

Melon.js Space Invaders Project - Grunt config is clearing resource file


I was trying to replicate the Space Invaders Project of Melon.js. It uses Grunt and the initial configuration is clearing the file that contains the player images.

resources: {
  dist: {
    options: {
      dest: 'build/js/resources.js',
      varname: 'game.resources',
    },
    files: [{
      src: ['data/bgm/**/*', 'data/sfx/**/*'],
      type: 'audio'
    },{
      src: ['data/img/**/*.png'],
      type: 'image'
    },{
      src: ['data/img/**/*.json'],
      type: 'json'
    },{
      src: ['data/map/**/*.tmx', 'data/map/**/*.json'],
      type: 'tmx'
    },{
      src: ['data/map/**/*.tsx'],
      type: 'tsx'
    }]
  }
},

How can I update the config so it doesn't clear the file /build/js/resources.js?

Cheers


Solution

  • If you are going to use the gruntfile as-is, you should let it construct the resources file based on resources in the source directory. In other words, do not hand-edit the files in the build/ directory.

    As an example, if you want to add a new png image to the resources.js file, just put the image file into the data/img/ subdirectory and the build process will correctly add it to resources.js for you.