Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add Babel to build process (close snowplow#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhadam committed Jan 18, 2019
1 parent 8513a28 commit cbfc65a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [["@babel/preset-env", {
"targets": {
"chrome": 32,
"ie": 9,
"firefox": 27,
"safari": 8
}
}]]
}
33 changes: 25 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,23 @@ module.exports = function(grunt) {
files: {
'tests/pages/helpers.js': ['tests/scripts/helpers.js'],
'tests/pages/detectors.js': ['tests/scripts/detectors.js'],
'tests/pages/snowplow.js': ['src/js/init.js']
'tests/pages/bundle.js': ['src/js/init.js']
}
}
},

babel: {
options: {
presets: ['@babel/preset-env']
},
dist: {
files: {
'dist/bundle-postbabel.js': 'dist/bundle.js'
}
},
test: {
files: {
'tests/pages/snowplow.js': 'tests/pages/bundle.js'
}
}
},
Expand All @@ -101,7 +117,7 @@ module.exports = function(grunt) {
'banner': '<%= banner %>',
'process': true
},
src: ['dist/bundle.js'],
src: ['dist/bundle-postbabel.js'],
dest: 'dist/snowplow.js'
},
tag: {
Expand Down Expand Up @@ -175,6 +191,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('intern');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-babel');

grunt.registerTask('upload_setup', 'Read aws.json and configure upload tasks', function() {
var aws = grunt.file.readJSON('aws.json');
Expand Down Expand Up @@ -242,11 +259,11 @@ module.exports = function(grunt) {
});
});

grunt.registerTask('default', 'Build Browserify, add banner, and minify', ['browserify:main', 'concat:deploy', 'uglify:deploy']);
grunt.registerTask('publish', 'Upload to S3 and invalidate Cloudfront (full semantic version only)', ['upload_setup', 'browserify:main', 'concat:deploy', 'uglify:deploy', 's3:not_pinned', 'cloudfront:not_pinned']);
grunt.registerTask('publish-pinned', 'Upload to S3 and invalidate Cloudfront (full semantic version and semantic major version)', ['upload_setup', 'browserify:main', 'concat:deploy', 'uglify:deploy', 's3', 'cloudfront']);
grunt.registerTask('quick', 'Build snowplow.js, skipping building and minifying', ['browserify:main', 'concat:deploy']);
grunt.registerTask('test', 'Intern tests', ['browserify:test', 'intern']);
grunt.registerTask('travis', 'Intern tests for Travis CI', ['concat:test', 'browserify:test', 'intern']);
grunt.registerTask('default', 'Build Browserify, add banner, and minify', ['browserify:main', 'babel:dist', 'concat:deploy', 'uglify:deploy']);
grunt.registerTask('publish', 'Upload to S3 and invalidate Cloudfront (full semantic version only)', ['upload_setup', 'browserify:main', 'babel:dist', 'concat:deploy', 'uglify:deploy', 's3:not_pinned', 'cloudfront:not_pinned']);
grunt.registerTask('publish-pinned', 'Upload to S3 and invalidate Cloudfront (full semantic version and semantic major version)', ['upload_setup', 'browserify:main', 'babel:dist', 'concat:deploy', 'uglify:deploy', 's3', 'cloudfront']);
grunt.registerTask('quick', 'Build snowplow.js, skipping building and minifying', ['browserify:main', 'babel:dist', 'concat:deploy']);
grunt.registerTask('test', 'Intern tests', ['browserify:test', 'babel:test', 'intern']);
grunt.registerTask('travis', 'Intern tests for Travis CI', ['concat:test', 'browserify:test', 'babel:test', 'intern']);
grunt.registerTask('tags', 'Minifiy the Snowplow invocation tag', ['uglify:tag', 'concat:tag']);
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
"sha1": "git://github.com/pvorb/node-sha1.git#910081c83f3661507d9d89e66e3f38d8b59d5559"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"JSON": "1.0.0",
"babel-cli": "^6.26.0",
"grunt": "0.4.5",
"grunt-aws": "0.6.2",
"grunt-browserify": "5.0.0",
"grunt-babel": "^8.0.0",
"grunt-browserify": "^5.0.0",
"grunt-contrib-concat": "0.5.1",
"lodash": "^4.17.11",
"grunt-contrib-uglify": "^4.0.0",
Expand Down

0 comments on commit cbfc65a

Please sign in to comment.