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

What's hot (20)

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

Viewers also liked (19)

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

More from Bo-Yi Wu (12)

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

Recently uploaded (20)

PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Practical Applications of AI in Local Government
OnBoard
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 

How to integrate front end tool via gruntjs