-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to include gulp-cdnizer in the generator #801
Comments
I don't know this plugin gulp. Maybe run new task after inject and before HTML task. But why you don't ask help to gulp-cdnizer repo ? |
I did :) |
heres my task. it runs off of the build task. i had probs w/ the bower dir too until i added relativeRoot param. gulp .task('cdnizer',function(){
return gulp .src('dist/index.html')
.pipe($.cdnizer({
allowRev: true,
allowMin:true,
relativeRoot:'bower_components',
fallbackTest:'<script>(function(){try{var lib="${ filepath }".split("../")[1];if(typeof ${ test } === "undefined"){cdnizerLoad(lib);}}catch(err){cdnizerLoad(lib);}})();</script>',
files: []
}))
.pipe(gulp.dest("dist"));
}); |
Hey @0101adm did that integration worked? Would you mind to tell me between what tasks did you put it? Thanks |
you will have to modify the 'other' task with this...
this will move bower_componenets into your dist root. you will need this for the cdnizer fallback. then this is your 'cdnizer' task...
if you install https://github.com/shahata/cdnjs-cdn-data you can use paths like...
then modify 'build' task with...
you will have to install https://www.npmjs.com/package/gulp-run-sequence to use runSequence. this will run cdnizer lastly. |
Thanks @0101adm! Wondering if you changed anything in your index.html too? Because its not working for me. This is the 'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var $ = require('gulp-load-plugins')();
gulp.task('cdnizer',function(){
return gulp.src('dist/index.html')
.pipe($.cdnizer({
allowRev: true,
allowMin:true,
relativeRoot:'bower_components',
fallbackTest:'<script>(function(){try{var lib="${ filepath }".split("../")[1];if(typeof ${ test } === "undefined"){cdnizerLoad(lib);}}catch(err){cdnizerLoad(lib);}})();</script>',
files: [
{
file:'bower_components/angular/angular.min.js',
cdn:'//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js',
test:'window.angular'
}]
}))
.pipe(gulp.dest("dist"));
}); And the other tasks gulp.task('other', function ()
{
var fileFilter = $.filter(function (file)
{
return file.stat.isFile();
});
gulp.src('./bower_components/**/*.js')
.pipe(gulp.dest('dist/bower_components'));
return gulp.src([
path.join(conf.paths.src, '/**/*'),
path.join('!' + conf.paths.src, '/**/*.{html,css,js,scss}')
])
.pipe(fileFilter)
.pipe(gulp.dest(path.join(conf.paths.dist, '/')));
});
gulp.task('build', function(callback) {
runSequence(['environment_config', 'html', 'fonts', 'other'], 'cdnizer',callback);
}); It runs but I can't see the cdn in the index file.
Any clue? Thanks!!! |
youre right. here is a blank copy.
|
mmm @0101adm is that the file you are using? because its not working. The one I have is:
The only different I have is: |
ill need more info / debug. |
Ok, not sure what else do you need, so would you mind to tell me? And I'll give it to you. Thanks! |
why isnt it working. |
I am very interested in this feature and would love to see it in vanilla generator. |
@zckrs @clement-escolano any new on this issue? |
@fuchao2012 |
@joaocc May you close the issue as it will not be fixed (unmaintained project) ? Thanks ! |
I have tried several options and I cannot get it to use CDN for bower_components packages.
I think the "inject" task is where this should run, and tried setting the relativeRoot and bowerComponents options, but to no avail.
Any hints? Thx
The text was updated successfully, but these errors were encountered: