美好的一天!
我关于gulpjs插件gulp-google-cdn的问题(我看到此插件here和here homepage):不会替换index.html中用于Google CDN网址的本地JQuery。
文件结构:
- /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'));
});
我尝试在index.html中写这个
<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>
但任务完成且URL未替换。
我的哪个不好?