npm安裝依賴
npm install --save-dev gulp gulp-typescript rollup rollup-plugin-typescript2 typescript
創(chuàng)建 gulpfile.js
const gulp = require("gulp");
const ts = require("gulp-typescript");
const rollup = require("rollup");
const typescript = require('rollup-plugin-typescript2');
gulp.task('default', function () {
return roComple();
})
function roComple() {
return rollup.rollup({
input: './src/Main.ts',
treeshake: true,//建議忽略
plugins: [
typescript({
check: false,
clean:true,
tsconfigOverride: { compilerOptions: { removeComments: true } }
}),
]
}).then(bundle => {
return bundle.write({
file: './bin/js/game.js',
format: 'iife',
name: 'mygame',
sourcemap: false
});
});
}