fix: use babili to minify ES6 sources.

This commit is contained in:
Luca Greco 2016-11-22 16:46:39 +01:00 committed by Luca Greco
parent 31d778c2cd
commit 9a38d923e9
2 changed files with 22 additions and 25 deletions

View File

@ -8,6 +8,8 @@ const LICENSE = `/* This Source Code Form is subject to the terms of the Mozilla
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */`;
const MINIFIED_FILE_FOOTER = `\n\n// <%= pkg.name %> v.<%= pkg.version %> (<%= pkg.homepage %>)\n\n${LICENSE}`;
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
@ -64,33 +66,25 @@ module.exports = function(grunt) {
},
},
"closure-compiler": {
dist: {
files: {
"dist/browser-polyfill.min.js": ["dist/browser-polyfill.js"],
},
babel: {
minify: {
options: {
// Closure currently supports only whitespace and comment stripping
// when both the input and output languages are ES6.
compilation_level: "WHITESPACE_ONLY",
language_in: "ECMASCRIPT6_STRICT",
language_out: "ECMASCRIPT6",
output_wrapper: `${LICENSE}\n%output%`,
babelrc: false,
comments: false,
presets: ["babili"],
sourceMap: true,
},
files: {
"dist/browser-polyfill.min.js": "dist/browser-polyfill.js",
},
},
},
// This currently does not support ES6 classes.
uglify: {
options: {
banner: LICENSE,
compress: true,
},
dist: {
files: {
"dist/browser-polyfill.min.js": ["dist/browser-polyfill.js"],
},
concat: {
license: {
src: "dist/browser-polyfill.min.js",
dest: "dist/browser-polyfill.min.js",
options: {footer: MINIFIED_FILE_FOOTER},
},
},
});
@ -99,7 +93,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-replace");
grunt.loadNpmTasks("grunt-umd");
grunt.loadNpmTasks("grunt-coveralls");
require("google-closure-compiler").grunt(grunt);
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-babel");
grunt.registerTask("default", ["eslint", "replace", "umd", "closure-compiler"]);
grunt.registerTask("default", ["eslint", "replace", "umd", "babel:minify", "concat:license"]);
};

View File

@ -17,10 +17,12 @@
},
"homepage": "https://github.com/mozilla/webextension-polyfill",
"devDependencies": {
"babel-preset-babili": "0.0.10",
"chai": "^3.5.0",
"eslint": "3.9.1",
"google-closure-compiler": "^20160911.0.0",
"grunt": "^1.0.1",
"grunt-babel": "^6.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-coveralls": "^1.0.1",
"grunt-replace": "*",
"grunt-umd": "^2.4.0",