2017-10-12 68 views
0

我知道这可能是一个非常愚蠢的问题,但我不能找到计算器上的其他职位匹配...局部变化node_modules到文件(角2)

所以:我可以修改文件的外部模块,只需保存文件,并做我的应用程序可以听的东西?目前,我试图在ng2-datepicker模块(在node_modules文件夹内)更改一些scss样式,但如果我保存并启动ng服务,更改不会影响我的项目。

我知道这是一个简单的问题,但我不知道Angular2项目的背景架构。

在此先感谢。

(PS我已经看到了,我可以用叉子叉混帐,然后像做NPM安装。 很有意思,但我也想知道如何在当地同样的结果)

回答

1

如果你是使用一饮而尽文件你可以告诉改变的库文件路径中的代码复制到build文件夹检查gulp.task(“复制库”)下面git repo for angular2-tour-of-heroes using gulp

const gulp = require('gulp'); 
const del = require('del'); 
const typescript = require('gulp-typescript'); 
const tscConfig = require('./tsconfig.json'); 
const sourcemaps = require('gulp-sourcemaps'); 
const tslint = require('gulp-tslint'); 
const browserSync = require('browser-sync'); 
const reload = browserSync.reload; 
const tsconfig = require('tsconfig-glob'); 

// clean the contents of the distribution directory 
gulp.task('clean', function() { 
    return del('dist/**/*'); 
}); 

// copy static assets - i.e. non TypeScript compiled source 
gulp.task('copy:assets', ['clean'], function() { 
    return gulp.src(['app/**/*', 'index.html', 'styles.css', '!app/**/*.ts'], { base : './' }) 
    .pipe(gulp.dest('dist')) 
}); 

// copy dependencies 
gulp.task('copy:libs', ['clean'], function() { 
    return gulp.src([ 
     'node_modules/angular2/bundles/angular2-polyfills.js', 
     'node_modules/systemjs/dist/system.src.js', 
     'node_modules/rxjs/bundles/Rx.js', 
     'node_modules/angular2/bundles/angular2.dev.js', 
     'node_modules/angular2/bundles/router.dev.js', 
     'node_modules/node-uuid/uuid.js', 
     'node_modules/immutable/dist/immutable.js' 
     'yourpath/changedFileName.js' 
    ]) 
    .pipe(gulp.dest('dist/lib')) 
}); 

// linting 
gulp.task('tslint', function() { 
    return gulp.src('app/**/*.ts') 
    .pipe(tslint()) 
    .pipe(tslint.report('verbose')); 
}); 


// TypeScript compile 
gulp.task('compile', ['clean'], function() { 
    return gulp 
    .src(tscConfig.files) 
    .pipe(sourcemaps.init()) 
    .pipe(typescript(tscConfig.compilerOptions)) 
    .pipe(sourcemaps.write('.')) 
    .pipe(gulp.dest('dist/app')); 
}); 

// update the tsconfig files based on the glob pattern 
gulp.task('tsconfig-glob', function() { 
    return tsconfig({ 
    configPath: '.', 
    indent: 2 
    }); 
}); 

// Run browsersync for development 
gulp.task('serve', ['build'], function() { 
    browserSync({ 
    server: { 
     baseDir: 'dist' 
    } 
    }); 

    gulp.watch(['app/**/*', 'index.html', 'styles.css'], ['buildAndReload']); 
}); 

gulp.task('build', ['tslint', 'compile', 'copy:libs', 'copy:assets']); 
gulp.task('buildAndReload', ['build'], reload); 
gulp.task('default', ['build']); 
+0

我从来没有使用过一口,但i'ts很有趣。似乎有点复杂的本地变化,但我会安装它! – Tommolo