-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
46 lines (42 loc) · 1.43 KB
/
gulpfile.js
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
var gulp = require('gulp'),
path = require('path'),
header = require('gulp-header'),
webpack = require('webpack'),
gulpWebpack = require('gulp-webpack'),
extend = require('util')._extend,
pkg = require('./package.json'),
clone = require('clone'),
distPath = path.join(__dirname, 'dist'),
webpackBuildConfig = require("./webpack.config.build");
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @author <%= pkg.author %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''
].join('\n');
gulp.task('default', ['build']);
gulp.task('build', ['build:dev', 'build:prod']);
gulp.task("build:dev", function (callback) {
var webpackConfig = clone(webpackBuildConfig);
webpackConfig.output.filename = pkg.name + '.js';
return gulp.src(webpackConfig.entry)
.pipe(gulpWebpack(webpackConfig))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest(distPath));
});
gulp.task("build:prod", function (callback) {
var webpackConfig = clone(webpackBuildConfig);
webpackConfig.output.filename = pkg.name + '.min.js';
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin());
return gulp.src(webpackConfig.entry)
.pipe(gulpWebpack(webpackConfig))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest(distPath));
});