Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_.each(dataPages, function (value, key, list) {
console.log('Awaiting psi-report for: ' + url + '/' + key +'.html');
psi.output(url + '/' + key +'.html',{
nokey: 'true', // or use key: ‘YOUR_API_KEY’
strategy: 'desktop',
}).then(() => {
psi.output(url + '/' + key +'.html',{
nokey: 'true', // or use key: ‘YOUR_API_KEY’
strategy: 'mobile',
});
});
});
}
// Note: this uses an unsigned certificate which on first access
// will present a certificate warning in the browser.
// https: true,
server: 'dist',
baseDir: "dist"
});
});
// Build Production Files, the Default Task
gulp.task('default', ['clean'], function(cb) {
runSequence('styles', ['html', 'scripts', 'styles', 'images', 'fonts', 'sounds', 'copy', 'copy-workerscripts'], cb);
});
// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
// By default, we use the PageSpeed Insights
// free (no API key) tier. You can use a Google
// Developer API key if you have one. See
// http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
url: 'https://example.com',
strategy: 'mobile'
}));
// Load custom tasks from the `tasks` directory
// try { require('require-dir')('tasks'); } catch (err) { console.error(err); }
gulp.task('pagespeed', cb => {
// Update the below URL to the public URL of your site
pagespeed('example.com', {
strategy: 'mobile',
// By default we use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'YOUR_API_KEY'
}, cb);
});
gulp.task('desktop', ['mobile'], function (cb) {
// output a formatted report to the terminal
psi.output(site, {
strategy: 'desktop',
locale: 'en_US',
threshold: 80
}, cb);
});
gulp.task('psi:desktop', ['serve:tunnelled'], function() {
var site = browserSync.instance.tunnel.url;
// Ensure http protocol is used to avoid breaking resources.
site = site.replace(/^https?/, 'http');
// Add user-defined path.
site = site + (psiPath || '');
return psi.output(site, {
nokey: 'true',
strategy: 'desktop',
threshold: 1 // Prevents error if score is below default of 70.
});
});
gulp.task('pagespeed', 'Run PageSpeed Insights', (cb) =>{
// Update the below URL to the public URL of your site
pagespeed.output(packageJSON.homepage, {
strategy: 'mobile' // desktop
// Use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'API_KEY'
}, cb);
});
gulp.task('pagespeed', function (cb) {
// Update the below URL to the public URL of your site
pagespeed.output('example.com', {
strategy: 'mobile',
// By default we use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'YOUR_API_KEY'
}, cb);
});
gulp.task('psi:mobile', ['serve:tunnelled'], function() {
var site = browserSync.instance.tunnel.url;
// Ensure http protocol is used to avoid breaking resources.
site = site.replace(/^https?/, 'http');
// Add user-defined path.
site = site + (psiPath || '');
return psi.output(site, {
nokey: 'true',
strategy: 'mobile',
threshold: 1 // Prevents error if score is below default of 70.
});
});
gulp.task('pagespeed', cb =>
// Update the below URL to the public URL of your site
pagespeed(
'https://www.dancedeets.com/new_homepage',
{
strategy: 'mobile',
// By default we use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'YOUR_API_KEY'
},
cb
)
);
// CSS and JS.
.pipe($.vulcanize({ dest: 'dist', strip: true }))
.pipe($.size({title: 'html'}));
});
// Clean Output Directory
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
// Build Production Files, the Default Task
gulp.task('default', ['clean'], function (cb) {
runSequence(['styles', 'copy'], ['jshint', 'html', 'images'], cb);
});
// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
// By default, we use the PageSpeed Insights
// free (no API key) tier. You can use a Google
// Developer API key if you have one. See
// http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
url: 'https://todomvc.com',
strategy: 'mobile'
}));
gulp.task('serve', function (cb) {
app.listen(8080, cb);
});
gulp.task('test-server', function (cb) {
app.listen(8000, cb);
});