Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gulp] Gulp 使用紀錄 #24

Open
CityRay opened this issue Aug 9, 2017 · 0 comments
Open

[gulp] Gulp 使用紀錄 #24

CityRay opened this issue Aug 9, 2017 · 0 comments

Comments

@CityRay
Copy link
Owner

CityRay commented Aug 9, 2017

Install

確認是否安裝過 Gulp

$ npm -g ls --depth=0

Npm Global Install Gulp

$ npm install -g gulp

Usage

Create gulpfile.js

gulp.task('mytask', function () {
    console.log('執行 default 的任務');
});

執行 gulp

$ gulp mytask

plugin

.pipe(header('\ufeff'))
  • gulp-replace
    可運用 regex replace,取代檔案中的指定文字
.pipe(replace(/ReplaceByGulp/ig, 'new text'))
// bundle.config.js
module.exports = {
  bundle: {
    main: {
      scripts: [
        './content/js/foo.js',
        './content/js/baz.js'
      ],
      styles: './content/**/*.css'
    },
    vendor: {
      scripts: './bower_components/angular/angular.js'
    }
  },
  copy: './content/**/*.{png,svg}'
};

gulp.js 中加入

gulp.task('bundle', function() {
  return gulp.src('./bundle.config.js')
    .pipe(bundle())
    .pipe(gulp.dest('./public'));
});

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant