Можно с помощью gulp + webpack или gulp + browserify или просто webpack.
Вот что использую я gulp + webpack:
let gulp = require('gulp');
let webpackStream = require('webpack-stream');
let webpack = webpackStream.webpack;
let named = require('vinyl-named');
const scripts = {
test: /\.js$/,
exclude: [/develop\/app/,],
query:{
presets: ['es2015']
},
loader: 'babel-loader'
};
const annotate = {
test: /\.js$/,
loader: 'ng-annotate'
}
const markup = {
test: /\.html$/,
loader: 'ngtemplate!html'
};
const uglify = {
test: /\.js$/,
loader: 'uglify'
};
let config = {
devtool: 'sourcemap',
module: {
loaders: [uglify, scripts, annotate, markup]
},
plugins: [
new webpack.NoErrorsPlugin()
]
};
gulp.task('buildModules', function(){
return gulp.src('develop/app/myModule.js')
.pipe(named())
.pipe(webpackStream(config))
.pipe(gulp.dest('build/app'))
};