Instantly share code, notes, and snippets.

Embed
What would you like to do?
オレの gulp
node_modules
[
{
"outputFileName": "bundle.js",
"inputFiles": [
"./src/**/*.js"
]
}
]
var gulp = require('gulp');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var merge = require('merge-stream');
var bundleconfig = require('./bundleconfig.json');
gulp.task('min:js', () => {
var tasks = bundleconfig.map(bundle =>
gulp.src(bundle.inputFiles, { base: "." })
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(concat(bundle.outputFileName))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest("."))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("."))
);
return merge(tasks);
});
gulp.task('watch', () => {
bundleconfig.forEach(bundle => {
gulp.watch(bundle.inputFiles, ["min:js"]);
});
});
{
"name": "name",
"version": "1.0.0",
"description": "",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-ng-annotate": "^2.0.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^2.0.0",
"merge-stream": "^1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment