Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('server', function() {
var port = 8000;
var build = gulp.env.type || 'default';
var indexPage = 'index' + (build === 'default' ? '' : '-' + build) + '.html';
var app = express();
// Log requests to the console
app.use(express.logger());
// If the file exists then supply it
app.use(express.static('build'));
// Otherwise just send the index.html for other files to support HTML5Mode
app.all('/*', function(req, res) {
res.sendfile(indexPage, { root: 'build' });
});
app.listen(port, function() {
gutil.log('Server listening on port', gutil.colors.magenta(port));
});
});
gulp.task('js', ['markdown-to-json'], function() {
// Browserify/bundle the JS.
browserify({
entries: './js/src/rosetta-stone.js',
insertGlobals : true,
fullPaths: true, // For discify
debug: ! gulp.env.production
}).bundle()
.pipe(source('rosetta-stone.js'))
.pipe(buffer())
.pipe(gulpIf(gulp.env.production, uglify()))
.pipe(gulp.dest('./js/dist'))
});
const fs = require('fs');
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const plumber = require('gulp-plumber');
const connect = require('gulp-connect');
const rename = require("gulp-rename");
const imagemin = require('gulp-imagemin');
const minifyHTML = require('gulp-minify-html');
const minifyInline = require('gulp-minify-inline');
const htmlAutoprefixer = require("gulp-html-autoprefixer");
const replace = require('gulp-replace');
const gm = require("gm");
const converter = require('image-to-icon-converter');
let VERSION = gulp.env.version;
if (!VERSION) {
VERSION = "v1";
}
let IS_DEBUG = !gulp.env.release;
let profile = gulp.env.profile;
if (!profile) {
profile = "gd";
}
let IS_OPTIMIZE_IMG = !!gulp.env.optmize;
console.log("是否调试模式:", IS_DEBUG);
console.log("PROFILE:", profile);
console.log("OPTIMIZE:", IS_OPTIMIZE_IMG);
console.log("版本:", VERSION);
gulp.task('sass', function () {
var sassOpts = {includePaths: [require('node-bourbon').includePaths, './lib/stylesheets']};
if(gulp.env.production) sassOpts.outputStyle = 'compressed';
gulp.src(['./bower_components/normalize.css/normalize.css', './lib/stylesheets/application.scss'])
.pipe(sass(sassOpts))
.pipe(concat(gulp.env.production ? 'dashboard.min.css' : 'dashboard.css'))
.pipe(gulp.dest('./build'));
});
gulp.task('test', function() {
gulp.src([
'test/mocha.conf.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'angular-re-captcha.js',
'test/unit/**/*.js'
]).pipe(karma({
configFile: './test/karma.config.js',
action: (gulp.env.travis ? 'run' : 'watch'),
browsers: (gulp.env.travis ? ['Firefox'] : ['Chrome']),
singleRun: (gulp.env.travis ? true : false),
}));
});
gulp.task('bump', function () {
return gulp.src(['./bower.json', './package.json'])
.pipe(bump({type: gulp.env.type}))
.pipe(gulp.dest('./'));
});
var gulp = require('gulp'),
exec = require('gulp-exec'),
protractor = require("gulp-protractor"),
lr = require('tiny-lr'),
livereload = require('gulp-livereload'),
server = lr(),
sourceStream = require('vinyl-source-stream'),
browserify = require('browserify'),
concat = require('gulp-concat');
var env = gulp.env.prod ? 'prod' : 'local';
var src = './app/',
dest = './couchapp/_attachments/';
var scripts = [
src+'components/lodash/dist/lodash.js',
src+'components/pouchdb-nightly/index.js',
src+'components/angular/angular.js',
src+'components/angular-route/angular-route.js',
src+'components/angular-sanitize/angular-sanitize.js',
src+'assets/app.js'
];
var styles = [
src+'components/normalize-css/normalize.css',
src+'styles/app.css'
]
gulp.task('scripts', () => {
gulp.src('src/index.js')
.pipe(plumber({ errorHandler: notify.onError('<%= error.message %>') }))
.pipe(browserify({
insertGlobals: true,
debug: !gulp.env.production
}))
.pipe(gulp.dest('./play'));
});
gulp.task('babel', () => {
return gulp.src('app/scripts.babel/**/*.js')
.pipe($.babel({
presets: ['es2015']
}))
.pipe(browserify({
insertGlobals : true,
debug : !gulp.env.production
}))
.pipe(gulp.dest('app/scripts'));
});
gulp.task('sass', function() {
gulp.src(paths.sass)
.pipe(sass({
outputStyle: 'compressed',
errLogToConsole: gulp.env.watch
}))
.pipe(gulp.dest('../public/css'));
});