Answer the question
In order to leave comments, you need to log in
gulp-google-cdn plugin not working?
Good day!
The question is: gulp-google-cdn plugin doesn't want to work, i.e. does not replace the JQuery link from local to that from the Google CDN in index.html.
I have the following folder structure
- /dist
- /src
-- /bower_components
-- index.html
- .bowerrc
- bower.json
- gulpfile.js
- package.json
bower.json
{
"name": "template",
"dependencies": {
"jquery": "~2.1.4",
"normalize-css": "normalize.css#~3.0.3",
"nodernizr-dev": "modernizr-dev#~3.1.0"
},
"overrides": {
"jquery": {
"main": "dist/jquery.min.js"
},
"normalize-css": {
"main": "normalize.css"
},
"nodernizr-dev": {
"main": "modernizr-latest.js"
}
}
}
{
"directory": "src/bower_components"
}
{
"name": "template",
"version": "0.0.1",
"devDependencies": {
"gulp": "^3.9.0",
"gulp-google-cdn": "^2.0.0"
}
}
var gulp = require('gulp');
var googlecdn = require('gulp-google-cdn');
gulp.task('cdn', function () {
return gulp.src('./src/index.html')
.pipe(googlecdn(require('./bower.json'), {
componentsPath: './src/bower_components/'
}))
.pipe(gulp.dest('./src'));
});
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="jquery/dist/jquery.min.js"></script>
Answer the question
In order to leave comments, you need to log in
My mistake was that I specified the minified file as the main one.
"overrides": {
"jquery": {
"main": "dist/jquery.min.js"
},
"overrides": {
"jquery": {
"main": "dist/jquery.js"
},
and this gulp-google-cdn plugin doesn’t work for me at all, I did everything as per the documentation and it doesn’t work (maybe I need to install something else for it? let’s say jquery 3.0 tried to make a link, it didn’t work out, maybe there is no such version on the CDN?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question