2015-11-07 38 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。 –