2015-11-07 37 views
1

在NetBeans 8.1中,bower_components文件夾存儲在Site Root文件夾之外。如何在NetBeans中使用Bower庫?

因此,我無法從bower_components將css或js文件加載到我的html中。

那麼,如何從Bower庫中加載文件?

enter image description here

回答

0

一應所需的文件複製到站點文件夾。

它可以通過手動或通過gulp和main-bower-files插件完成。

樣品gulpfile.js:

var gulp = require('gulp'); 
var mainBowerFiles = require('main-bower-files'); 


gulp.task('mainJS', function() { 
    return gulp.src(mainBowerFiles('**/*.js')) 
      .pipe(gulp.dest('public_html/libs/js')); 
}); 
gulp.task('mainLess', function() { 
    return gulp.src(mainBowerFiles('**/*.less')) 
      .pipe(gulp.dest('public_html/libs/less')); 
}); 
gulp.task('mainCSS', function() { 
    return gulp.src(mainBowerFiles('**/*.css')) 
      .pipe(gulp.dest('public_html/libs/css')); 
}); 

gulp.task('main-bower-files', ['mainJS', 'mainLess', 'mainCSS']); 
+0

當創建用於Netbeans 8.1新的HTML5/JS應用程序,你必須創建一個bower.json文件作爲嚮導的一部分的選項。如果這樣做,Netbeans會創建另一個名爲「.bowerrc」的文件,其中包含對bower_components文件夾的引用。現在,無論何時使用bower添加軟件包,都可以在Netbeans項目中使用,而無需手動複製或使用gulp。 –