SlideShare a Scribd company logo
打造團隊共同開發環境
2013.05.25 KSDG
高雄軟體開發者社群
2013 KSDG 2
Who am I
Bo-Yi Wu @appleboy
http://blog.wu-boy.com
https://github.com/appleboy
任職於瑞昱半導體 RealTek(IC Design House)
2013 KSDG 3
開發團隊
●
前端工程師
– UI, JavaScript, CSS Designer
●
後端工程師
– PHP, Ruby, Python Enginner
●
測試工程師
– Python, JavaScript Enginner
2013 KSDG 4
工程師都有自己的
Coding Style
2013 KSDG 5
每次要改別人的
程式碼都特別痛苦
2013 KSDG 6
好的專案看起來就
像是同一個人寫的
2013 KSDG 7
統一團隊開發環境
Windows, Linux, Mac
2013 KSDG 8
減少建置環境時間
2013 KSDG 9
前端工具
Html,CSS,JavaScript
2013 KSDG 10
前端工具
CSS
2013 KSDG 11
CSS 產生器
Sass/Scss
2013 KSDG 12
gem install compass
2013 KSDG 13
前端工具
JavaScript
2013 KSDG 14
JavaScript 產生器
2013 KSDG 15
npm install -g coffeescript
2013 KSDG 16
網頁總是會用到很多套件
jQuery,Backbone ...
2013 KSDG 17
外部套件版本控管
2013 KSDG 18
Package Manager
BowerBower
http://bower.io/
2013 KSDG 19
npm install -g bower
2013 KSDG 20
前端工具介紹到此
2013 KSDG 21
後端工程師
PHP,Ruby,Python
2013 KSDG 22
PHP Coding Style
PHP-FIG
PSR-0,1,2
http://www.php-fig.org/
2013 KSDG 23
自動修正
Coding Style
PHP-CS-Fixer
https://github.com/fabpot/PHP-CS-Fixer
2013 KSDG 24
寫 Server 端不再
是 PHP,Python
程式語言
2013 KSDG 25
JavScript Language
Node.jsNode.js
2013 KSDG 26
Node.js 發行速度快
2013 KSDG 27
管理 Node.js 版本
2013 KSDG 28
Node Version Manager
nvmnvm
https://github.com/creationix/nvm
2013 KSDG 29
How to use
●
nvm install 0.10.5
●
nvm ls
●
nvm ls-remote
●
nvm use 0.10.5
●
nvm install stable (support from my github)
●
nvm install latest (support from my github)
https://github.com/appleboy/nvm
2013 KSDG 30
減少每天按 Ctrl+F5 次數
LiveReload
2013 KSDG 31
整理上述工具 Command
2013 KSDG 32
Bower, Compass ...
●
bower install
●
compass watch .
●
coffee -b -w -c -o js/ coffeescript/
●
node build/server.js
●
guard start
2013 KSDG 33
要記住這麼多 Command
該如何整合成單一指令呢?
2013 KSDG 34
Makefile ?
2013 KSDG 35
build:
r.js -o build/app.build.js
compass:
compass watch .
coffee:
coffee -b -w -c -o js/ coffeescript/
livereload:
guard start
all: compass coffee livereload
2013 KSDG 36
Windows 開發環境可以跑嘛 ?
WTF
2013 KSDG 37
有沒有更簡單的方法
同時相容多種作業系統
Windows,Linux,Mac
2013 KSDG 38
JavaScript Task Runner
GruntJS
2013 KSDG 39
Why Use GruntJS
●
Define Task Runner
– Initial Project
– Deploy Project
– Unit Test Project
●
Designer Don't learning command line
●
Many Available Grunt plugins
– CoffeeScript, Compass, Jade, Require.js
– Twitter Bower, JSHint, CSSMin, Livereload
2013 KSDG 40
How the Grunt CLI works?
2013 KSDG 41
只需要兩個設定檔
2013 KSDG 42
package.json && Gruntfile.js
2013 KSDG 43
package.json
npm install grunt-cli --save-dev
npm init 建立此檔案
2013 KSDG 44
Gruntfile.js or Gruntfile.coffee
grunt.js for 0.3.x versions of Grunt.
2013 KSDG 45
Gruntfile.js 四大組合
●
The "wrapper" function
●
Project and task configuration
– compass, require.js, bower, shell.. etc.
●
Loading grunt plugins and tasks
●
Custom tasks
– Deploy, Clean, Build project … etc.
2013 KSDG 46
開始撰寫
Gruntfile.js
2013 KSDG 47
Gruntfile.js 四大組合
●
The "wrapper" function
●
Project and task configuration
– compass, require.js, bower, shell.. etc.
●
Loading grunt plugins and tasks
●
Custom tasks
– Deploy, Clean, Build project … etc.
2013 KSDG 48
module.exports = function(grunt) {
// Do grunt-related things in here
};
2013 KSDG 49
Gruntfile.js 四大組合
●
The "wrapper" function
●
Project and task configuration
– compass, require.js, bower, shell.. etc.
●
Loading grunt plugins and tasks
●
Custom tasks
– Deploy, Clean, Build project … etc.
2013 KSDG 50
grunt.initConfig({
pkg: project_config,
shell: {
bower: {
command: 'node node_modules/.bin/bower install',
options: {
callback: function(err, stdout, stderr, cb) {
console.log('Install bower package compeletely.');
return cb();
}
}
}
}
});
2013 KSDG 51
Gruntfile.js 四大組合
●
The "wrapper" function
●
Project and task configuration
– compass, require.js, bower, shell.. etc.
●
Loading grunt plugins and tasks
●
Custom tasks
– Deploy, Clean, Build project … etc.
2013 KSDG 52
grunt.loadNpmTasks('grunt-shell');
2013 KSDG 53
Gruntfile.js 四大組合
●
The "wrapper" function
●
Project and task configuration
– compass, require.js, bower, shell.. etc.
●
Loading grunt plugins and tasks
●
Custom tasks
– Deploy, Clean, Build project … etc.
2013 KSDG 54
// Default task(s).
grunt.registerTask('default', ['connect', 'watch']);
// Deploy task(s).
grunt.registerTask('release', ['htmlmin', 'cssmin']);
2013 KSDG 55
用 Grunt 整合開發工具
2013 KSDG 56
開發專案三步驟
●
Initialize Project
●
Test Project
●
Deploy Project
2013 KSDG 57
開發專案三步驟
●
Initialize Project
●
Test Project
●
Deploy Project
2013 KSDG 58
Initialize Project
●
Bower install
●
Create server via express.
●
Livereload
●
Coffeescript and compass
2013 KSDG 59
Initialize Project
●
Bower install
●
Create server via express.
●
Livereload
●
Coffeescript and compass
2013 KSDG 60
bower: {
install: {
options: {
cleanup: false,
install: true,
verbose: true,
copy: false
}
}
}
2013 KSDG 61
$ grunt bower:install
2013 KSDG 62
Initialize Project
●
Bower install
●
Create server via express
●
Livereload
●
Coffeescript and compass
2013 KSDG 63
express: {
dev: {
options: {
script: 'build/server.js'
}
}
}
2013 KSDG 64
$ grunt express:dev
2013 KSDG 65
不想自己寫
server code
2013 KSDG 66
connect: {
livereload: {
options: {
hostname: '0.0.0.0',
port: 4000,
base: '.'
}
}
}
2013 KSDG 67
$ grunt connect:livereload
2013 KSDG 68
Initialize Project
●
Bower install
●
Create server via express.
●
Livereload
●
Coffeescript and compass
2013 KSDG 69
livereload: {
port: 35729
}
2013 KSDG 70
偵測檔案變化
2013 KSDG 71
regarde: {
html: {
files: ['app/**/*.{html,htm}'],
tasks: ['livereload']
},
css: {
files: ['app/**/*.css'],
tasks: ['livereload']
},
js: {
files: 'app/**/*.js',
tasks: ['livereload']
}
}
2013 KSDG 72
Initialize Project
●
Bower install
●
Create server via express.
●
Livereload
●
Coffeescript and compass
2013 KSDG 73
regarde: {
scss: {
files: ['app/**/*.scss'],
tasks: ['compass:dev']
},
coffee: {
files: '**/*.coffee',
tasks: ['coffee']
}
}
2013 KSDG 74
Compass Task
2013 KSDG 75
compass: {
dev: {
options: {
sassDir: 'app/assets/sass',
cssDir: 'app/assets/css',
imagesDir: 'app/assets/images',
javascriptsDir: 'app/assets/js',
outputStyle: 'nested',
relativeAssets: true,
noLineComments: true,
environment: 'development'
}
}
}
2013 KSDG 76
Coffee Task
2013 KSDG 77
coffee: {
dev: {
expand: true,
cwd: 'app/assets/coffeescript/',
src: ['**/*.coffee'],
dest: 'app/assets/js/',
ext: '.js',
options: {
bare: true
}
}
}
2013 KSDG 78
開發專案三步驟
●
Initialize Project
●
Test Project
●
Deploy Project
2013 KSDG 79
定義 Test 工作
2013 KSDG 80
grunt.registerTask('test', ['release',
'shell:test', 'mocha_phantomjs']);
2013 KSDG 81
$ grunt test
2013 KSDG 82
開發專案三步驟
●
Initialize Project
●
Test Project
●
Deploy Project
2013 KSDG 83
上線前該做的事
2013 KSDG 84
Before Deploying Project
●
JavaScript Minify and Combine
(requirejs)
●
CSS Minify (cssmin)
●
Html Minify (htmlmin)
●
Remove unnecessary files (clean)
●
Copy files (copy)
2013 KSDG 85
JavaScript Minify and Combine
https://github.com/asciidisco/grunt-requirejs
2013 KSDG 86
requirejs: {
release: {
options: {
appDir: "app/",
baseUrl: "assets/js/",
dir: "public",
name: "main",
mainConfigFile: 'app/assets/js/main.js',
paths: {
jquery: '../vendor/jquery/jquery'
}
}
}
}
2013 KSDG 87
$ grunt requirejs:release
2013 KSDG 88
CSS Minify
https://github.com/gruntjs/grunt-contrib-cssmin
2013 KSDG 89
cssmin: {
release: {
report: 'gzip',
expand: true,
cwd: 'app/assets/css',
src: ['*.css'],
dest: 'app/assets/css'
}
}
2013 KSDG 90
$ grunt cssmin:release
2013 KSDG 91
Html Minify
https://github.com/gruntjs/grunt-contrib-htmlmin
2013 KSDG 92
htmlmin: {
options: {
removeComments: true,
collapseWhitespace: true
},
release: {
files: {
'public/index.html': 'app/index.html'
}
}
}
2013 KSDG 93
$ grunt htmlmin:release
2013 KSDG 94
Remove unnecessary files
https://github.com/gruntjs/grunt-contrib-clean
2013 KSDG 95
clean: {
options: {
force: true
},
release: ['app/assets/coffee',
'app/.sass-cache']
}
2013 KSDG 96
$ grunt clean:release
2013 KSDG 97
Copy files
https://github.com/gruntjs/grunt-contrib-copy
2013 KSDG 98
copy: {
release: {
files: [
{
src: 'app/js/main-built.js',
dest: 'public/js/20130519.js'
}
]
}
}
2013 KSDG 99
$ grunt copy:release
2013 KSDG 100
今日所有整合都在 Github
https://github.com/appleboy/html5-template-engine
2013 KSDG 101
Html5 Template Engine
https://github.com/appleboy/html5-template-engine
2013 KSDG 102
●
The latest html5boilerplate.com source
code
●
Includes Normalize.scss v2.1.x and v1.1.x.
●
The latest jQuery and Modernizr.
●
Support CoffeeScript, RequireJS, Compass
●
A lightweight web server listen to 4000
port
●
Support JavaScript Task Runner GruntJS
●
Support JavaScript test framework Mocha
2013 KSDG 103
歡迎 Fork
打造團隊開發環境
https://github.com/appleboy/html5-template-engine
2013 KSDG 104
Live Demo

More Related Content

PDF
Gearman work queue in php
PDF
Automating your workflow with Gulp.js
PDF
JCConf 2015 workshop 動手玩 Java 專案建置工具
PPTX
PHP & JavaScript & CSS Coding style
PDF
Frontend JS workflow - Gulp 4 and the like
PPTX
drone continuous Integration
PDF
Automating Large Applications on Modular and Structured Form with Gulp
PDF
Drupal contrib module maintaining
Gearman work queue in php
Automating your workflow with Gulp.js
JCConf 2015 workshop 動手玩 Java 專案建置工具
PHP & JavaScript & CSS Coding style
Frontend JS workflow - Gulp 4 and the like
drone continuous Integration
Automating Large Applications on Modular and Structured Form with Gulp
Drupal contrib module maintaining

What's hot (20)

PDF
Drone CI/CD Platform
PDF
Drone 1.0 Feature
PDF
Live deployment, ci, drupal
PDF
Google App Engine: Basic
PDF
CI : the first_step: Auto Testing with CircleCI - (MOSG)
PDF
DrupalCon Los Angeles - Continuous Integration Toolbox
PDF
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
PDF
Continuous Integration & Continuous Delivery with GCP
PDF
CIbox - OpenSource solution for making your #devops better
PPTX
Using Multi-stage Docker, Go, Java,& Bazel to DESTROY Long Build Times
PDF
Rest, sockets em golang
PDF
GraphQL IN Golang
PDF
Devfest 2021' - Artifact Registry Introduction (Taipei)
PPTX
Deployment Patterns in the Ruby on Rails World
PDF
Gitlab ci e kubernetes, build test and deploy your projects like a pro
PDF
Drone CI/CD 自動化測試及部署
PDF
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
PDF
Introduction to GitHub Actions
PDF
Building scala with bazel
PDF
Gdg cloud taipei ddt meetup #53 buildpack
Drone CI/CD Platform
Drone 1.0 Feature
Live deployment, ci, drupal
Google App Engine: Basic
CI : the first_step: Auto Testing with CircleCI - (MOSG)
DrupalCon Los Angeles - Continuous Integration Toolbox
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Continuous Integration & Continuous Delivery with GCP
CIbox - OpenSource solution for making your #devops better
Using Multi-stage Docker, Go, Java,& Bazel to DESTROY Long Build Times
Rest, sockets em golang
GraphQL IN Golang
Devfest 2021' - Artifact Registry Introduction (Taipei)
Deployment Patterns in the Ruby on Rails World
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Drone CI/CD 自動化測試及部署
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
Introduction to GitHub Actions
Building scala with bazel
Gdg cloud taipei ddt meetup #53 buildpack
Ad

Viewers also liked (19)

PDF
advanced introduction to codeigniter
PDF
Introduction to Grunt.js on Taiwan JavaScript Conference
PDF
Introduction to MVC of CodeIgniter 2.1.x
PPTX
Git flow 與團隊合作
PPTX
Why to choose laravel framework
PPTX
用 Docker 改善團隊合作模式
PPTX
Write microservice in golang
PDF
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
PPTX
Git Flow and JavaScript Coding Style
PDF
Phpconf 2011 introduction_to_codeigniter
PDF
You must know about CodeIgniter Popular Library
PDF
Introduction to git
PPTX
How to choose web framework
PDF
RESTful API Design & Implementation with CodeIgniter PHP Framework
PPTX
Docker 基礎介紹與實戰
PDF
Maintainable PHP Source Code
PPT
Introduction to Android G Sensor I²C Driver on Android
PDF
Git-flow workflow and pull-requests
PDF
Linux kernel tracing
advanced introduction to codeigniter
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to MVC of CodeIgniter 2.1.x
Git flow 與團隊合作
Why to choose laravel framework
用 Docker 改善團隊合作模式
Write microservice in golang
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
Git Flow and JavaScript Coding Style
Phpconf 2011 introduction_to_codeigniter
You must know about CodeIgniter Popular Library
Introduction to git
How to choose web framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
Docker 基礎介紹與實戰
Maintainable PHP Source Code
Introduction to Android G Sensor I²C Driver on Android
Git-flow workflow and pull-requests
Linux kernel tracing
Ad

More from Bo-Yi Wu (12)

PDF
用 Go 語言打造多台機器 Scale 架構
PDF
Job Queue in Golang
PDF
Golang Project Layout and Practice
PPTX
Go 語言基礎簡介
PPTX
Gorush: A push notification server written in Go
PPTX
用 Drone 打造 輕量級容器持續交付平台
PPTX
用 Go 語言 打造微服務架構
PPTX
Introduction to Gitea with Drone
PDF
運用 Docker 整合 Laravel 提升團隊開發效率
PDF
用 Go 語言實戰 Push Notification 服務
PPTX
用 Go 語言打造 DevOps Bot
PPTX
A painless self-hosted Git service: Gitea
用 Go 語言打造多台機器 Scale 架構
Job Queue in Golang
Golang Project Layout and Practice
Go 語言基礎簡介
Gorush: A push notification server written in Go
用 Drone 打造 輕量級容器持續交付平台
用 Go 語言 打造微服務架構
Introduction to Gitea with Drone
運用 Docker 整合 Laravel 提升團隊開發效率
用 Go 語言實戰 Push Notification 服務
用 Go 語言打造 DevOps Bot
A painless self-hosted Git service: Gitea

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
KodekX | Application Modernization Development
PPTX
A Presentation on Artificial Intelligence
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
MYSQL Presentation for SQL database connectivity
Big Data Technologies - Introduction.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KodekX | Application Modernization Development
A Presentation on Artificial Intelligence
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Building Integrated photovoltaic BIPV_UPV.pdf
Understanding_Digital_Forensics_Presentation.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
MYSQL Presentation for SQL database connectivity

How to integrate front end tool via gruntjs