Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Webpack
Search
Yu Xin
October 18, 2016
Programming
2
110
Webpack
Webpack introduce.
Yu Xin
October 18, 2016
Tweet
Share
More Decks by Yu Xin
See All by Yu Xin
Clojure Introduction (Chinese)
is
0
82
Other Decks in Programming
See All in Programming
CSC509 Lecture 04
javiergs
PRO
0
290
WebエンジニアがSwiftをブラウザで動かすプレイグラウンドを作ってみた
ohmori_yusuke
0
170
ポスターセッション: 「まっすぐ行って、右!」って言ってラズパイカーを動かしたい 〜生成AI × Raspberry Pi Pico × Gradioの試作メモ〜
komofr
0
950
開発生産性を上げるための生成AI活用術
starfish719
1
170
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
0
380
LLMとPlaywright/reg-suitを活用した jQueryリファクタリングの実際
kinocoboy2
4
670
エンジニアとして高みを目指す、 利益を生み出す設計の考え方 / design-for-profit
minodriven
23
12k
Django Ninja による API 開発効率化とリプレースの実践
kashewnuts
0
930
CSC509 Lecture 06
javiergs
PRO
0
240
Swift Concurrency - 状態監視の罠
objectiveaudio
2
450
CSC509 Lecture 05
javiergs
PRO
0
290
『毎日の移動』を支えるGoバックエンド内製開発
yutautsugi
2
180
Featured
See All Featured
Writing Fast Ruby
sferik
629
62k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.5k
Site-Speed That Sticks
csswizardry
11
880
A designer walks into a library…
pauljervisheath
209
24k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
580
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
How STYLIGHT went responsive
nonsquared
100
5.8k
The World Runs on Bad Software
bkeepers
PRO
71
11k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Transcript
前端部署
[email protected]
》Webpack
传统的网页
Web App时代的前端
新的挑战 • 越来越复杂的项目结构 • 模块化的javascript • 版本管理 • 模块依赖 •
打包发布
迷茫 • JS模块化. module定义 AMD, CMD, ... • 包管理工具 NPM,
Bower, Browserify ... • 构建工具 grunt, gulp, ...
常见的模式 • 纯静态目录结构 • 开发调试时保持原始结构,发布的时候再统一 打包 • 开发过程就提供工具,直接打包 SourceMap, LiveUpdate
gulp + bower • bower作为包管理器 • 支持browersync的开发服务器 • gulp pipeline负责构建过程
• wiredep负责打包以及js/css注入 • 通过插件支持angularjs template打包
Webpack
参考项目 • react-starter-kit https://github.com/kriasoft/react-starter-kit 仅仅使用Webpack作为打包工具, 项目构建依赖gulp • redux-sample https://github.com/rackt/redux 使用Webpack作为完整的开发构建部署工具
使用webpack-dev-server作为开发服务器
体验Webpack • npm安装依赖的javascript 模块 配置webpack.config.js • 了解webpack的基本概念 - loader, plugin
进一步扩展webpack配置
基本的Webpack配置
index.html
安装依赖 npm install -g webpack webpack-dev-server …… npm install --save
react npm install --save react-redux npm install --save redux ……
开发过程 • 配置好webpack.config.js webpack-dev-server相关配置 • 启动webpack-dev-server • webpack-dev-server会自动监控相关的资源 文件变化,自动重新打包
Webpack + NPM • Webpack支持npm打包的javascript library/framework • Webpack缺省配置会自动搜索node_modules 下的模块 webpack
--config webpack.config.js
Webpack 的原理 • 通过分析程序中的require调用构建依赖关系 • 通过loader支持其他的资源(css, less, sass, json …)
css/less/sass最后会转换成js postcss
引入css • 理解loader基本概念 • 根据需要添加loader • 代码中添加相关资源的require
安装相关的loader模块 npm install --save-dev css-loader webpack.config.js
添加css依赖
更多功能 • webpack-dev-server • source-map • react-hot-reload • more and
more http://webpack.github.io/docs/ • angular-template-loader https://github.com/WearyMonkey/ngtemplate-loader https://github.com/teux/ng-cache-loader
使用感受 • All in One. 一个工具解决大部分问题. • 支持React Hot Reload
… very cool. • 支持module css.
使用中的困惑 • 非javascript模块的依赖关系处理 • js uglify & minify • duplicated
dependencies
Thanks. The End