如何设置npm package.json将“ dist”文件安装到我的项目中?

时间:2019-06-07 10:39:41

标签: github npm plugins installation package.json

我该如何设置npm package.json来更新和安装来自github的插件,而不仅仅是将其安装到我根目录下的node_modules中,例如将dist文件从bootstrap放入我的文件夹root / web / css / bootstrap中,而不是root / node_modules / bootstrap中?我当时在想,npm可以将插件直接安装到特定的文件夹中,这样我就可以更轻松地管理所有插件。

我找到了这个,我可以用gulp插件

var gulp        = require('gulp');
var browserSync = require('browser-sync').create();
var sass        = require('gulp-sass');

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
    return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'])
        .pipe(sass())
        .pipe(gulp.dest("src/css"))
        .pipe(browserSync.stream());
});

// Move the javascript files into our /src/js folder
gulp.task('js', function() {
    return gulp.src(['node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/jquery/dist/jquery.min.js', 'node_modules/tether/dist/js/tether.min.js'])
        .pipe(gulp.dest("src/js"))
        .pipe(browserSync.stream());
});

// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {

    browserSync.init({
        server: "./src"  
    });

    gulp.watch(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'], ['sass']);
    gulp.watch("src/*.html").on('change', browserSync.reload);
});

gulp.task('default', ['js','serve']);

0 个答案:

没有答案