in Gruntfile.js [23:72]
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compile: {
android: {},
ios: {},
osx: {},
windows: { useWindowsLineEndings: true },
browser: {},
electron: {}
},
clean: ['pkg']
});
// custom tasks
grunt.registerMultiTask('compile', 'Packages cordova.js', function () {
const done = this.async();
const platformPath = path.resolve(`../cordova-${this.target}`);
const platformPkgPath = path.join(platformPath, 'package');
const platformModulesPath = path.join(platformPath, 'cordova-js-src');
build({
platformName: this.target,
platformVersion: grunt.option('platformVersion') ||
require(platformPkgPath).version,
extraModules: collectModules(platformModulesPath)
})
.then(cordovaJs => {
// if we are using windows line endings, we will also add the BOM
if (this.data.useWindowsLineEndings) {
cordovaJs = '\ufeff' + cordovaJs.split(/\r?\n/).join('\r\n');
}
// Write out the bundle
const baseName = `cordova.${this.target}.js`;
const fileName = path.join('pkg', baseName);
grunt.file.write(fileName, cordovaJs);
console.log(`Generated ${fileName}`);
})
.then(done, done);
});
// external tasks
grunt.loadNpmTasks('grunt-contrib-clean');
// defaults
grunt.registerTask('default', ['compile']);
};