Skip to content

Commit 3963ae8

Browse files
author
Shuwen Qian
committed
Add prod build to gulpfile
1 parent 45c63ab commit 3963ae8

2 files changed

Lines changed: 64 additions & 11 deletions

File tree

Gulpfile.js

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var vulcanize = require('gulp-vulcanize');
1414
var debug = require('gulp-debug');
1515
var run = require('run-sequence');
1616
var htmlmin = require('gulp-minify-html');
17+
var inlinemin = require('gulp-minify-inline');
1718
var wrap = require('gulp-wrap');
1819
var inlineAssets = require('gulp-inline-assets');
1920
var marked = require('gulp-marked');
@@ -22,6 +23,9 @@ var es = require('event-stream');
2223
var cache = require('gulp-cached');
2324
var postcss = require('gulp-postcss');
2425
var autoprefixer = require('autoprefixer');
26+
var git = require('gulp-git');
27+
var bump = require('gulp-bump');
28+
var tag_version = require('gulp-tag-version');
2529

2630
var SRC = 'src/';
2731
var BUILD = 'build/';
@@ -50,7 +54,7 @@ gulp.task('sass', function() {
5054
.pipe(sass({includePaths: ['./bower_components/bourbon/app/assets/stylesheets/', './src/shared/sass/']}).on('error', sass.logError))
5155
.pipe(postcss([autoprefixer({browsers: ['last 2 versions']})]))
5256
.pipe(gulp.dest(BUILD))
53-
// .pipe(wrap({src:TEMPLATES + "style_module_template.html"},{},{engine:"hogan"}))
57+
.pipe(wrap({src:TEMPLATES + "style_module_template.html"},{},{engine:"hogan"}))
5458
.pipe(wrap(function(data) {
5559
data.fname = path.basename(data.file.relative,'.css');
5660
return wrapper;
@@ -79,11 +83,7 @@ gulp.task('vulcanize', function() {
7983
imports: ['.*polymer\.html']
8084
}
8185
}))
82-
.pipe(htmlmin({
83-
quotes: true,
84-
empty: true,
85-
spare: true
86-
}))
86+
.pipe(htmlmin())
8787
.pipe(gulp.dest(BUILD));
8888
var lib = gulp.src(BUILD + "strand.html")
8989
.pipe(vulcanize({
@@ -106,21 +106,45 @@ gulp.task('build', function(cb) {
106106
run('copy', ['sass','font'],'vulcanize', cb);
107107
});
108108

109+
gulp.task('build:prod', function(cb) {
110+
run('clean', ['build', 'vulcanize:prod', 'copy:prod'], cb);
111+
});
112+
109113
gulp.task('vulcanize:prod', function() {
110-
return gulp.src(BUILD + "mm-*/mm-*.html")
114+
return gulp.src(BUILD + 'strand.html')
111115
.pipe(vulcanize({
112-
inlineScripts:true,
113-
inlineCss:true,
114-
stripExcludes:false
116+
inlineScripts:true,
117+
inlineCss:true,
118+
stripExcludes:false
115119
}))
116120
.pipe(htmlmin({
117121
quotes: true,
118122
empty: true,
119123
spare: true
120124
}))
125+
.pipe(inlinemin())
121126
.pipe(gulp.dest(BUILD));
122127
});
123128

129+
gulp.task('copy:prod', function() {
130+
return gulp.src([BUILD+'**/*.+(html|woff)', '!'+BUILD+'/shared/**/*.html', '!'+BUILD +'**/example.html'])
131+
.pipe(changed(DIST))
132+
.pipe(debug())
133+
.pipe(gulp.dest(DIST));
134+
});
135+
136+
// gulp.task('minify:prod', function() {
137+
// return gulp.src(BUILD+'strand.html')
138+
// .pipe(debug())
139+
// .pipe(htmlmin({
140+
// quotes: true,
141+
// empty: true,
142+
// spare: true
143+
// }))
144+
// .pipe(inlinemin())
145+
// .pipe(gulp.dest(DIST))
146+
// });
147+
124148
/** DOCS **/
125149

126150
gulp.task('docs', function() {
@@ -145,3 +169,28 @@ gulp.task('watch', function () {
145169
});
146170

147171
/** DEPLOY **/
172+
173+
gulp.task('build:prod', ['clean', 'copy', 'sass', 'font', 'vulcanize:prod']);
174+
175+
gulp.task('bump:major', function(){
176+
return gulp.src(['package.json', 'bower.json'])
177+
.pipe(bump({type: 'major'}))
178+
.pipe(gulp.dest('./'));
179+
});
180+
gulp.task('bump:minor', function(){
181+
return gulp.src(['package.json', 'bower.json'])
182+
.pipe(bump({type: 'minor'}))
183+
.pipe(gulp.dest('./'));
184+
});
185+
gulp.task('bump:patch', function(){
186+
return gulp.src(['package.json', 'bower.json'])
187+
.pipe(bump({type: 'patch'}))
188+
.pipe(gulp.dest('./'));
189+
});
190+
191+
gulp.task('stage-release', function() {
192+
var pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
193+
return gulp.src([DIST, 'package.json', 'bower.json', 'CHANGELOG.md'])
194+
.pipe(git.add())
195+
.pipe(git.commit('Release v'+pkg.version));
196+
});

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,19 @@
3737
"grunt-text-replace": "^0.4.0",
3838
"grunt-vulcanize": "^1.0.0",
3939
"gulp": "^3.9.0",
40+
"gulp-bump": "^1.0.0",
4041
"gulp-cached": "^1.1.0",
4142
"gulp-changed": "^1.3.0",
4243
"gulp-debug": "^2.1.2",
44+
"gulp-git": "^1.7.0",
4345
"gulp-inline-assets": "^0.1.1",
4446
"gulp-marked": "^1.0.0",
45-
"gulp-minify-html": "^1.0.4",
47+
"gulp-minify-html": "^1.0.5",
48+
"gulp-minify-inline": "^0.2.0",
4649
"gulp-postcss": "^6.0.1",
4750
"gulp-rename": "^1.2.2",
4851
"gulp-sass": "^2.1.0",
52+
"gulp-tag-version": "^1.3.0",
4953
"gulp-util": "^3.0.7",
5054
"gulp-vulcanize": "^6.0.1",
5155
"gulp-wrap": "^0.11.0",

0 commit comments

Comments
 (0)