mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-27 08:40:10 +02:00
add offline enabled build process
This commit is contained in:
37
gulpfile.js
Normal file
37
gulpfile.js
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
var gulp = require('gulp');
|
||||
// var uglify = require('gulp-uglify');
|
||||
// var minifyCSS = require('gulp-csso');
|
||||
var useref = require('gulp-useref');
|
||||
|
||||
gulp.task('css', function(){
|
||||
return gulp.src([
|
||||
'src/lib/codemirror/lib/codemirror.css',
|
||||
'src/lib/codemirror/addon/hint/show-hint.css',
|
||||
'src/lib/codemirror/addon/fold/foldgutter.css',
|
||||
'src/lib/hint.min.css',
|
||||
'src/lib/inlet.css',
|
||||
'src/style.css',
|
||||
])
|
||||
.pipe(concat('build.css'))
|
||||
.pipe(minifyCSS())
|
||||
.pipe(gulp.dest('src'))
|
||||
});
|
||||
|
||||
gulp.task('useRef', [],function() {
|
||||
return gulp.src('src/index.html')
|
||||
.pipe(useref())
|
||||
.pipe(gulp.dest('dist'));
|
||||
});
|
||||
|
||||
gulp.task('generate-service-worker', [ 'useRef' ], function(callback) {
|
||||
var swPrecache = require('sw-precache');
|
||||
var rootDir = 'dist';
|
||||
|
||||
swPrecache.write(`${rootDir}/service-worker.js`, {
|
||||
staticFileGlobs: [rootDir + '/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff}'],
|
||||
stripPrefix: rootDir
|
||||
}, callback);
|
||||
});
|
||||
|
||||
gulp.task('default', [ 'generate-service-worker' ]);
|
Reference in New Issue
Block a user