SlideShare une entreprise Scribd logo
1  sur  77
Télécharger pour lire hors ligne
vuedinner #3
Vue
@wainfo
github: andyyou
2
•
•
• webpack
• vue-loader
• vue-cli
• vue templates (webpack)
•
• HTML
• CSS
• Javascript
• Assets(Images, Fonts)
EB
• HTML - Templates
• CSS - Sass, Less, PostCSS
• Javascript - Compile To Javascript
•
•
•
• Lint
• Debug Tools
• Bower, npm
• Browserify, RequireJS
• Grunt
• gulp, fly
• Brunch
• webpack
• jspm
• rollup
http://j.mp/2bhpkQL
> ls -al | grep whoami
pipe
gulp.src(paths.scripts)
.pipe(sourcemaps.init())
.pipe(coffee())
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/js'));
ES2015 Generator style
Javascript
require('module')
> npm install -g browserify
> browserify [src] -o > [dist]
webpack
• •
• ES6 Module Loader Polypill
• SystemJS Universal Dynamic Module Loader
Any type of module format can be loaded and it will
be detected automatically by SystemJS.
jspm?
http://j.mp/2aNmimZ
webpack
• npm +
• grunt, gulp
• requires, browserify
• webpack + ( )
• jspm + + + ( )
• rollup, fly,
webpack
•
• / (2014)
•
•
• HRM
• loaders & plugins
• Code Splitting (sync, async chunk)
•
•
webpack
•
• /
•
•
• HRM
• loaders & plugins
• Code Splitting (sync, async chunk)
•
•
webpack
...
•
•
•
•
•
•
•
webpack
1.
1.
2.
2.
3.
4.
vue with webpack
http://j.mp/2bzJl36
# npm/nvm
> mkdir vuedinner && cd vuedinner
> npm init -y
> npm i webpack -D
https://github.com/andyyou/vue-dinner-demo
> webpack <entry> <output>
> webpack e1.js e2.js bundle.js
> webpack andyyou=./entry.js "[name].js"
>> output a andyyou.js file.
// webpack.config.js
module.exports = {
output: {
filename: "[name].bundle.js"
}
}
1. index.html
2. main.js index.js
3.
4. webpack
loaders
Javascript
> npm i css-loader style-loader file-loader -D
!
> webpack main.js bundle.js —output-public-path=‘/dist/'
--module-bind 'css=style!css' --module-bind 'png=file'
webpack-dev-server + plugins
> npm i webpack-dev-server -D
• dll
• css ( )
• , , ,
• HTML5 Cache mainfest
• Offline (ServiceWorker)
• HRM
• s3
•
plugins
ES2015 + Vue
1.
2. webpack.config.js
3. .babelrc
4. ( Vue.js)
https://github.com/babel/babel-loader
# webpack: webapck
# webpack-dev-server:
# webpack-merge: (webpack.config.js)
# css-loader: css
# style-loader: css html
# file-loader:
# url-loader: base64
# babel-core: ES2015 babel
# babel-loader: ES2015
# babel-plugin-transform-runtime: polyfilling ( babel-runtime)
# babel-preset-es2015: es2015
# babel-preset-stage-0:
# babel-runtime: ES2015+ helpers, polyfilling
`class MyClass {}` -> `_classCallCheck` AST
# vue-loader: vue
# vue-html-loader: vue template
# vue-style-loader: vue
# vue-hot-reload-api: Hot reload API for Vue components
vue-loader
vue-loader
• <template>
• HTML
• vue <template>
•
• <script>
• javascript ES2015 Babel
• vue <script>
• JS CommonJS require
• import ES2015
• script Vue - Vue.extend()
• <style>
• css
• <style>
• `sytle-loader` <head> <style>
• webpack css
src CommonJS require
• ./
• module/dist/all.css npm
<template src="./template.html"></template>
<style src="./style.css"></style>
<script src="./script.js"></script>
vue-style!css![options]!rewriter(postcss)
Source Code
• autpprefixer
• scoped
• postcss + cssnext
vue-hot-reload-api 2.0.6
Hot Reload
vue-loader loader
webpack loader jade-loader
function HTML String jade
jade-loader
• file-loader
• url-loader base64 HTTP request
url(image.png) > require(‘file!./image.png')
> npm i vue-loader vue-html-loader vue-style-loader vue-hot-reload-
api@1 -D
# 1. webpack.config.js
# 2. main.js app.vue
> webpack-dev-server --inline --hot
Hot Module Replacement / Hot Reload
webpack-dev-server
• Iframe mode
http://localhost:8080/webpack-dev-server/index.html
• Inline mode
webpack-dev-server client entry bundle
--hot
—hot = HotModuleReplacementPlugin
https://github.com/webpack/webpack-dev-server/blob/
2eef9e64e4528dfda756d61c627d4b5a49bbae8e/bin/
webpack-dev-server.js#L240-L257
https://medium.com/@rajaraodv/webpack-
the-confusing-parts-58712f8fcad9#.
6z7z6wx8q
JS
+
vue-loader
vue-cli
> npm install -g vue-cli
> vue init <template-name> <project-name>
> vue init webpack v-project
webpack
webpack dev middleware plugins
• webpack dev middleware
• webpack hot middleware
• html-webpack-plugin
• html-webpack-template
• extract-text-webpack-plugin
Vue - PASSER
Vue 淺談前端建置工具
Vue 淺談前端建置工具
Vue 淺談前端建置工具
Vue 淺談前端建置工具

Contenu connexe

Tendances

NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
Dmytro Ovcharenko
 

Tendances (20)

Famo.us - New generation of HTML5 Web Application Framework
Famo.us - New generation of HTML5 Web Application FrameworkFamo.us - New generation of HTML5 Web Application Framework
Famo.us - New generation of HTML5 Web Application Framework
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thing
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
遠端團隊專案建立與管理 remote team management 2016
遠端團隊專案建立與管理 remote team management 2016遠端團隊專案建立與管理 remote team management 2016
遠端團隊專案建立與管理 remote team management 2016
 
Vue.js
Vue.jsVue.js
Vue.js
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
 
Vuex
VuexVuex
Vuex
 
Vue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerVue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue router
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
 
Vuejs for Angular developers
Vuejs for Angular developersVuejs for Angular developers
Vuejs for Angular developers
 
Using VueJS in front of Drupal 8
Using VueJS in front of Drupal 8Using VueJS in front of Drupal 8
Using VueJS in front of Drupal 8
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
 
Vue Introduction
Vue IntroductionVue Introduction
Vue Introduction
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
 
Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.js
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.js
 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue Material
 

Similaire à Vue 淺談前端建置工具

WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)
Shumpei Shiraishi
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
Lucas Jellema
 
SnapyX
SnapyXSnapyX
SnapyX
ekino
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 

Similaire à Vue 淺談前端建置工具 (20)

Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
 
Building JavaScript
Building JavaScriptBuilding JavaScript
Building JavaScript
 
Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of Sinatra
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
 
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
 
WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?
 
Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
 
Vue.js + Vuexチーム開発実践の事例
Vue.js + Vuexチーム開発実践の事例Vue.js + Vuexチーム開発実践の事例
Vue.js + Vuexチーム開発実践の事例
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 
SnapyX
SnapyXSnapyX
SnapyX
 
SnapyX - ParisJS
SnapyX - ParisJSSnapyX - ParisJS
SnapyX - ParisJS
 
Improve your web dev workflow in Visual Studio
Improve your web dev workflow in Visual StudioImprove your web dev workflow in Visual Studio
Improve your web dev workflow in Visual Studio
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 

Vue 淺談前端建置工具