S
S
Sergey Tereshko2015-10-23 23:42:54
JavaScript
Sergey Tereshko, 2015-10-23 23:42:54

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"
    }
  }
}

.bowerrc
{
  "directory": "src/bower_components"
}

package.json
{
  "name": "template",
  "version": "0.0.1",
  "devDependencies": {
    "gulp": "^3.9.0",
    "gulp-google-cdn": "^2.0.0"
  }
}

gulpfile.js
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'));
});

In the index.html itself, I tried to put the line
<script src="bower_components/jquery/dist/jquery.min.js"></script>

then this
<script src="../bower_components/jquery/dist/jquery.min.js"></script>

and in the end it
<script src="jquery/dist/jquery.min.js"></script>
doesn't help at all.
Gulp writes that the task is completed, but there is no result in index.html.
What to do?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Tereshko, 2015-10-28
@stereshko

My mistake was that I specified the minified file as the main one.

"overrides": {
    "jquery": {
      "main": "dist/jquery.min.js"
    },

If you specify a regular one, then the link from the Google CDN will be affixed and it will be affixed minified
"overrides": {
    "jquery": {
      "main": "dist/jquery.js"
    },

S
shmenski, 2016-06-29
@shmenski

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 question

Ask a Question

731 491 924 answers to any question