Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grunt-babel example from readme generates exception #31

Closed
breeeew opened this issue May 8, 2015 · 4 comments
Closed

grunt-babel example from readme generates exception #31

breeeew opened this issue May 8, 2015 · 4 comments

Comments

@breeeew
Copy link

breeeew commented May 8, 2015

'use strict';

module.exports = function(grunt) {

require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

grunt.initConfig({
    babel: {
        options: {
            sourceMap: true
        },
        dist: {
            files: {
                'dist/app.js': 'src/app.js'
            }
        }
    }
});

grunt.registerTask('default', ['babel']);
};

generates exception:

grunt
Running "babel:dist" (babel) task
Warning: path must be a string Use --force to continue.

Aborted due to warnings.
@breeeew breeeew closed this as completed May 8, 2015
@anthonybrown
Copy link

I'm getting the same error, how did you solve this?

@agdm
Copy link

agdm commented Jul 24, 2015

same here.

@breeeew
Copy link
Author

breeeew commented Jul 25, 2015

I wrote incorrectly "files" section. My sources placed in "src_babel/", and i build it to "build/", and i wrote:

dist: {
  files: {
    'src_babel/**/*.js': 'build/'
  }
}

My fixed and full Grunfile:

'use strict';

module.exports = function(grunt) {
  grunt.initConfig({
    clean: ['build/', 'test_build/'],
    jasmine_node: {
        options: {
            forceExit: true,
            match: '.',
            matchall: false,
            extensions: 'js',
            specNameMatcher: ''
        },
        all: ['test_build/']
    },
    coffee: {
        compile: {
            options: {
                bare: true
            },
            expand: true,
            cwd: 'src',
            src: ['**/*.coffee'],
            dest: 'build/',
            ext: '.js'
        },
        compileTests:
        {
            cwd: 'test',
            expand: true,
            src: ['**/*.coffee'],
            dest: 'test_build/',
            ext: '.js'
        }
    },
    coffeelint: {
        app: ['src/**/*.coffee', '!src/test/**/*.coffee', '!src/node_modules/**'],
        options: {
            'max_line_length' : {
                'level': 'ignore'
            }
        }
    },
    babel: {
      options: {
        sourceMap: true,
        stage: 0,
        optional: ['runtime']
      },
      dist: {
        files: [{
          expand: true,     // Enable dynamic expansion.
          cwd: 'src_babel/',      // Src matches are relative to this path.
          src: ['**/*.js'],
          dest: 'build/',   // Destination path prefix.
          ext: '.js',   // Dest filepaths will have this extension.
          extDot: 'first'   // Extensions in filenames begin after the first dot
        }]
      },
      test: {
        options: {
          sourceMap: false
        },
        files:[{
          expand: true,     // Enable dynamic expansion.
          cwd: 'test_babel/',      // Src matches are relative to this path.
          src: ['**/*.js'],
          dest: 'test_build/',   // Destination path prefix.
          ext: '.js',   // Dest filepaths will have this extension.
          extDot: 'first'   // Extensions in filenames begin after the first dot
        }]
      }
    }
});

    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-coffeelint');
    grunt.loadNpmTasks('grunt-jasmine-node');
    grunt.loadNpmTasks('grunt-babel');

    // Default task.
    grunt.registerTask('default', ['clean', 'coffee', 'babel', 'jasmine_node']);

    grunt.registerTask('lint', ['coffeelint']);
    grunt.registerTask('test', ['jasmine_node']);
};

@tandrewnichols
Copy link

This error actually happens anytime the src files are empty, which feels like a problem. If we want to migrate our existing infrastructure from using es5 to es6, we might want to specify the files that grunt-babel should compile as some/directory/**/*.es6 and then we can make changes as we go. But this fails until at least one *.es6 file exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants