Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Last active September 2, 2016 13:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsakamoto/ce0bd81fb36628d594a81b76593f0cd1 to your computer and use it in GitHub Desktop.
Save jsakamoto/ce0bd81fb36628d594a81b76593f0cd1 to your computer and use it in GitHub Desktop.
オレの 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