用webpack构建一个常规项目,好处和坏处分析
生活随笔
收集整理的這篇文章主要介紹了
用webpack构建一个常规项目,好处和坏处分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?最近項目改版,用webpack重新架構.
些許心得我會寫幾篇記錄一下.
好處如下:
1.ES6語法用起來,babel-loader轉義,各種新語法用起來.
2.import 語法寫起來,webpack2.0以上版本直接支持.模塊化開發大勢所趨.寫代碼變為享受.
import 'pages/liveing/style.scss' import FastClick from 'fastclick' import config from 'configModule' import wx from 'weixin-js-sdk' import '../libs/lib.prototype' import './log.js' import _util_ from '../libs/libs.util'3.圖片直接轉base64,減少請求.
4.頁面樣式 JS調試特別的方便,熱更新真的特別好用.
5.支持ejs語法,直接輸出靜態頁面來.公共html模塊,可以抽取出來共用.
<!doctype html> <html lang="en"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="hotcss" content="initial-dpr=1"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="x5-page-mode" content="no-title"><meta name="format-detection" content="telephone=no"><meta name="applicable-device" content="mobile"><link rel="canonical" href="<%= canonical %>"/><meta name="Copyright" content="東方體育?版權所有"><link rel="shortcut icon" href="<%= DIRS.BUILD_FILE.images.favicon %>"><link rel="bookmark" href="<%= DIRS.BUILD_FILE.images.favicon %>" type="image/x-icon"><link rel="apple-touch-icon-precomposed" href="<%= DIRS.BUILD_FILE.images.favicon %>"><link rel="dns-prefetch" href="<%= HOME_URL %>"><title><%= pageTitle %></title><meta name="keywords" content="<%= pageKeywords %>"><meta name="description" content="<%= pageDescription %>">不好的地方:
某些低級瀏覽器不支持熱替換.沒辦法調試,必須輸出代碼后調試,這樣出現bug,調試很累.
webpack配置報錯,錯誤信息不是很明顯,出現錯誤,很不好修復.官方文檔也不是很詳盡.
轉載于:https://www.cnblogs.com/chengfeng6/p/7767103.html
總結
以上是生活随笔為你收集整理的用webpack构建一个常规项目,好处和坏处分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iwannadadandan下载链接
- 下一篇: JAVA开发环境的搭建(配置JAVA开发