1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false; const useCMDNode = process.argv[1].indexOf("layaair2-cmd") > -1 ? true : false;
function useOtherNode(){ return useIDENode||useCMDNode; }
let ideModuleDir = useOtherNode() ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : ""; let workSpaceDir = useOtherNode() ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\compile.js", "").replace("/.laya/compile.js", "") : "./../";
const gulp = require(ideModuleDir + "gulp"); const rollup = require(ideModuleDir + "rollup"); const typescript = require(ideModuleDir + 'rollup-plugin-typescript2'); const glsl = require(ideModuleDir + 'rollup-plugin-glsl');
let prevTasks = ""; if (global.publish) { prevTasks = ["loadConfig"]; }
gulp.task("compile", prevTasks, function () { if (global.publish && !global.config.compile) { return; } else if (global.publish && global.config.compile) { workSpaceDir = global.workSpaceDir; }
return rollup.rollup({ input: workSpaceDir + '/src/Main.ts', onwarn:(waring,warn)=>{ if(waring.code == "CIRCULAR_DEPENDENCY"){ console.log("warnning Circular dependency:"); console.log(waring); } }, treeshake: false, plugins: [ typescript({ tsconfig:workSpaceDir + "/tsconfig.json", check: true, tsconfigOverride:{compilerOptions:{removeComments: true}}, include:/.*.ts/, }), glsl({ include: /.*(.glsl|.vs|.fs)$/, sourceMap: true, compress:false }),
] }).then(bundle => { return bundle.write({ file: workSpaceDir + '/bin/js/bundle.js', format: 'iife', name: 'laya', sourcemap: true }); }).catch(err=>{ console.log(err); }) });
|