fix: use babili to minify ES6 sources.
This commit is contained in:
parent
31d778c2cd
commit
9a38d923e9
43
Gruntfile.js
43
Gruntfile.js
|
@ -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"]);
|
||||
};
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue