1. 程式人生 > >webpack從零開始第1課:安裝webpack和webpack-dev-server

webpack從零開始第1課:安裝webpack和webpack-dev-server

webpack目錄

本文參考文件

前提條件

  • 電腦裝了一個全新的nodejs,最好是LTS版本,舊的nodejs版本可能沒使用webpack的新功能,也可能會丟失一些依賴的包
  • 先安裝好淘寶的cnpm,淘寶映象方便些
  • 我的安裝環境是win10

一:安裝webpack和webpack-dev-server

1.準備工作

  • 新建專案資料夾D:\03www2018\study\webpack2017 下面簡寫為 根目錄
  • 新建npm配置檔案package.josn,根目錄>cnpm init

2.專案區域性安裝webpack和webpack-dev-server

  • 不建議全域性安裝webpack和webpack-dev-server
  • 區域性安裝webpack 根目錄>cnpm i webpack -D
  • 區域性安裝server 根目錄>cnpm i webpack-dev-server -D
  • 會自動生成node_modules資料夾,下有804個資料夾(485+319server)個資料夾,這些包都是webpack的依賴
  • package.json中增加了剛安裝的包webpack的配置
"devDependencies": {
  "webpack": "^3.10.0",
  "webpack-dev-server": "^2.9.7"
}
說明1: devDependencies是開發依賴,只會在打包過程中用到,不會包含到最後的程式碼中
說明2: 如果想安裝指定版本的webpack,使用npm install --save-dev
[email protected]
<版本號>格式

3.熟悉webpack命令列各引數的意思

  • 有關命令列各引數的用法,根目錄>"node_modules/.bin/webpack" -h
  • 上面這個執行webpack很不方便,修改根目錄>package.json,在script加上兩條
  "scripts": {
    "a" :"webpack --config ./build/webpack.dev.conf.js",
    "b" :"webpack-dev-server --config ./build/webpack.dev.conf.js",
    "test": "echo \"
Error: no test specified\" && exit 1" },
  • 命令列的選項其實都可以寫在配置檔案webpack.config.js中,寫在配置檔案中更方便更強大。webpack啟動時要讀取配置檔案,引數--config指定讀取哪個配置檔案,如果沒有使用--config指定,會預設在根目錄中找webpack.config.jswebpackfile.js這個檔案,有關配置檔案的命名隨意定,但最好帶上環境,如webpack.base|dev|prod.conf.js
01: 配置選項 Config options:
  --config       配置檔案路徑,字串格式,預設是`根目錄`下的 webpack.config.js 或 webpackfile.js,
  --config-name  使用配置的名字,字串
  --env          當配置檔案輸出的是一個函式時,要指定,在下一節課中會介紹

02: 基本選項 Basic options:
  --context    入口檔案根目錄,預設為當前目錄
  --entry      入口檔案,這裡只能是字串,但在配置檔案中還可以定義陣列或物件
  --watch, -w  監視是否有檔案有改動,會自動打包,預設為false
  --debug      Switch loaders to debug mode                            [boolean]
  --devtool    Enable devtool for better debugging experience (Example:
               --devtool eval-cheap-module-source-map)                  [string]
  -d           shortcut for --debug --devtool eval-cheap-module-source-map
               --output-pathinfo                                       [boolean]
  -p           shortcut for --optimize-minimize --define
               process.env.NODE_ENV="production"                       [boolean]
  --progress   Print compilation progress in percentage                [boolean]

03: 模組選項 Module options:
  --module-bind       Bind an extension to a loader                     [string]
  --module-bind-post                                                    [string]
  --module-bind-pre                                                     [string]

04: 輸出選項 Output options:
  --output-path                 The output path for compilation assets
                                       [string] [default: The current directory]
  --output-filename             The output filename of the bundle
                                                   [string] [default: [name].js]
  --output-chunk-filename       The output filename for additional chunks
       [string] [default: filename with [id] instead of [name] or [id] prefixed]
  --output-source-map-filename  The output filename for the SourceMap   [string]
  --output-public-path          The public path for the assets          [string]
  --output-jsonp-function       The name of the jsonp function used for chunk
                                loading                                 [string]
  --output-pathinfo             Include a comment with the request for every
                                dependency (require, import, etc.)     [boolean]
  --output-library              Expose the exports of the entry point as library
                                                                        [string]
  --output-library-target       The type for exposing the exports of the entry
                                point as library                        [string]

05: 高階選項 Advanced options:
  --records-input-path       Path to the records file (reading)         [string]
  --records-output-path      Path to the records file (writing)         [string]
  --records-path             Path to the records file                   [string]
  --define                   Define any free var in the bundle          [string]
  --target                   The targeted execution environment         [string]
  --cache                    Enable in memory caching
                      [boolean] [default: It's enabled by default when watching]
  --watch-stdin, --stdin     Exit the process when stdin is closed     [boolean]
  --watch-aggregate-timeout  Timeout for gathering changes while watching
  --watch-poll               The polling interval for watching (also enable
                             polling)                                   [string]
  --hot                      Enables Hot Module Replacement            [boolean]
  --prefetch                 Prefetch this request (Example: --prefetch
                             ./file.js)                                 [string]
  --provide                  Provide these modules as free vars in all modules
                             (Example: --provide jQuery=jquery)         [string]
  --labeled-modules          Enables labeled modules                   [boolean]
  --plugin                   Load this plugin                           [string]
  --bail                     Abort the compilation on first error
                                                       [boolean] [default: null]
  --profile                  Profile the compilation and include information in
                             stats                     [boolean] [default: null]

06: 解析選項 Resolving options:
  --resolve-alias         Setup a module alias for resolving (Example:
                          jquery-plugin=jquery.plugin)                  [string]
  --resolve-extensions    Setup extensions that should be used to resolve
                          modules (Example: --resolve-extensions .es6,.js)
                                                                         [array]
  --resolve-loader-alias  Setup a loader alias for resolving            [string]

07: 優化選項 Optimizing options:
  --optimize-max-chunks      Try to keep the chunk count below a limit
  --optimize-min-chunk-size  Try to keep the chunk size above a limit
  --optimize-minimize        Minimize javascript and switches loaders to
                             minimizing                                [boolean]

08: 統計選項 Stats options:
  --color, --colors               Enables/Disables colors on the console
                                           [boolean] [default: (supports-color)]
  --sort-modules-by               Sorts the modules list by property in module
                                                                        [string]
  --sort-chunks-by                Sorts the chunks list by property in chunk
                                                                        [string]
  --sort-assets-by                Sorts the assets list by property in asset
                                                                        [string]
  --hide-modules                  Hides info about modules             [boolean]
  --display-exclude               Exclude modules in the output         [string]
  --display-modules               Display even excluded modules in the output
                                                                       [boolean]
  --display-max-modules           Sets the maximum number of visible modules in
                                  output                                [number]
  --display-chunks                Display chunks in the output         [boolean]
  --display-entrypoints           Display entry points in the output   [boolean]
  --display-origins               Display origins of chunks in the output
                                                                       [boolean]
  --display-cached                Display also cached modules in the output
                                                                       [boolean]
  --display-cached-assets         Display also cached assets in the output
                                                                       [boolean]
  --display-reasons               Display reasons about module inclusion in the
                                  output                               [boolean]
  --display-depth                 Display distance from entry point for each
                                  module                               [boolean]
  --display-used-exports          Display information about used exports in
                                  modules (Tree Shaking)               [boolean]
  --display-provided-exports      Display information about exports provided
                                  from modules                         [boolean]
  --display-optimization-bailout  Display information about why optimization
                                  bailed out for modules               [boolean]
  --display-error-details         Display details about errors         [boolean]
  --display                       Select display preset (verbose, detailed,
                                  normal, minimal, errors-only, none)   [string]
  --verbose                       Show more details                    [boolean]

09: 選項 Options:
  --help, -h     顯示幫助資訊                                            
  --version, -v  版本號                                  
  --json, -j     將結果以JSON格式顯示 

4.準備專案資料夾及檔案

為了更好地演示和學習webpack,請建好下列資料夾和檔案

專案根目錄
│   package.json
├───node_modules
│       └╌╌ 下面是npm包
├───dist
│     └╌╌╌╌╌logo.jpg 
├───build
│   ├╌╌╌╌╌ build.js
│   ├╌╌╌╌╌ webpack.base.conf.js
│   ├╌╌╌╌╌ webpack.dev.conf.js
│   └╌╌╌╌╌ webpack.prod.conf.js
├───src
│   ├╌╌╌╌╌ main.js
│   └╌╌╌╌╌tmp
│         ├╌╌╌╌╌home.js
│         ├╌╌╌╌╌about.js
│         └╌╌╌╌╌contact.js
│   └╌╌╌╌╌template
│         └╌╌╌╌╌daqi.html // 為hmtl外掛的模板
│   └╌╌╌╌╌images
│         └╌╌╌╌╌logo.jpg  

先只需寫這幾個檔案,後面會陸續補充

二:打包

準備配置檔案

  • 根目錄/build/webpack.dev.conf.js的內容如下,這是史上最簡單的配置檔案了
module.exports = {
    entry: './src/main', //main.js中的.js可以省略,前面的./不能省
    output:{
        filename:'./dist/app.js' // dist資料夾不存在時,會自動建立
    }
}
  • 根目錄/src/main.js中隨便寫一句
console.log('hello,歡迎來到零和壹線上課堂')

打包

D:\03www2018\study\webpack2017>npm run a,顯示如下

> [email protected]1.0.0 a D:\03www2018\study\webpack2017
> webpack --config ./build/webpack.dev.conf.js

Hash: 94dc0f2301921649904c  // complication的hash值,它的長度和演算法由output中相應的項決定
Version: webpack 3.10.0 // webpack的版本
Time: 55ms // 打包花費的時間
        Asset    Size  Chunks             Chunk Names
./dist/app.js  2.5 kB       0  [emitted]  main //單個檔案和陣列的chunk名字預設為main 
   [0] ./src/main.js 32 bytes {0} [built]

開啟打包後的檔案看下,整體是一個自執行檔案,每個檔案是一個模組做為自執行函式的引數

三:開啟伺服器

先啟動看下,根目錄>npm run b
從啟動的資訊中可以看到,它包含了上面的打包,專案的網址是http://localhost:8080/,可以在瀏覽器中開啟看下效果,但由於沒有指定入口檔案,所以會顯示當前目錄的內容,有一點必須明白,伺服器打包的後的檔案並沒有物理存在電腦上,只是在記憶體中,為了方便教程的講解,在這裡先講下伺服器的配置,有關全部配置的講解,請參考下一篇文章:配置檔案詳解

3.1 使用HtmlWebpackPlugin外掛生成首頁

首頁一般為一個html檔案,我們到現在還沒有定義,為了方便,順便提前瞭解一下webpack的外掛功能,我這裡使用HtmlWebpackPlugin來生成首頁,外掛的使用基本相同,分以下幾步

  • 第一步安裝 根目錄>cnpm i -D html-webpack-plugin
  • 修改配置檔案 根目錄/build/webpack.dev.conf.js
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin'); //第二步匯入
module.exports = {
    entry: './src/main', //main.js中的js可以省略,前面的./不能省
    output:{
        filename:'./dist/[hash]app.js',
        hashDigestLength: 8 // 預設長度是20
    },
    plugins: [new HtmlWebpackPlugin], //第三步,例項化後放在plugins這個陣列中就行
    devServer: {
      contentBase: path.join(__dirname, "../dist"), //網站的根目錄為 根目錄/dist,如果配置不對,會報Cannot GET /錯誤
      port: 9000, //埠改為9000
      open:true // 自動開啟瀏覽器,適合懶人
    }
}

生成的html檔案只在記憶體中,並沒有存在物理磁碟上,來看一下生成的內容,留心下生成的js檔案中的hash值,它的長度是8位,就是上面hashDigestLength: 8定義的

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Webpack App</title>
  </head>
  <body>
  <script type="text/javascript" src="./dist/4e0c807aapp.js"></script></body>
</html>

html-webpack-plugin的用途

  • 對於打包的檔名中有hash的,這個外掛是必選,因為每次原始檔修改,打包後的名字就不一樣
  • 生成一個html5模板檔案,可適用於lodash模板,也可以利用自己定義的載入器
  • js注入,打包後的js檔案會自動注入到html檔案的body結尾部分(預設,也可以注入到head部分)
  • css檔案注入,假如你使用ExtractTextPlugin外掛(這個外掛也是必須要了解的)將css檔案是單獨剝離出來,不放在html中的style標籤內,它會自動將css連結注入到link標籤中

html-webpack-plugin外掛完整配置

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig={
    title: 'hello,零和壹線上課堂', // html5檔案中<title>部分
    filename: 'front.html', // 預設是index.html,伺服器中設定的首頁是index.html,如果這裡改成其它名字,那麼devServer.index改為和它一樣,最終完整檔案路徑是output.path+filename,如果filename中有子資料夾形式,如`./ab/cd/front.html`,只取`./front.html`
    template: './src/template/daqi.html', //如果覺得外掛預設生成的hmtl5檔案不合要求,可以指定一個模板,模板檔案如果不存在,會報錯,預設是在專案根目錄下找模板檔案,才模板為樣板,將打包的js檔案注入到body結尾處
    inject:head, // true|body|head|false,四種值,預設為true,true和body相同,是將js注入到body結束標籤前,head將打包的js檔案放在head結束前,false是不注入,這時得要手工在html中加js
}
module.exports = {
    entry: './src/main', //main.js中的js可以省略,前面的./不能省
    output:{
        filename:'./dist/[hash]app.js',
        hashDigestLength: 8
    },
    plugins: [new HtmlWebpackPlugin(HtmlWebpackPluginConfig)], //先不配置外掛,看看效果
    devServer: {
      contentBase: path.join(__dirname, "../dist"), //網站的根目錄為 根目錄/dist
      port: 9000, //埠改為9000
      open:true, // 自動開啟瀏覽器
      index:'front.html' // 與HtmlWebpackPlugin中配置filename一樣
    }
}

3.2 devServer常用配置

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig={
    title: 'hello,零和壹線上課堂', // html5檔案中<title>部分
    filename: 'front.html', // 預設是index.html,伺服器中設定的首頁是index.html,如果這裡改成其它名字,那麼devServer.index改為和它一樣
    template: './src/template/daqi.html', // 如果覺得外掛預設生成的hmtl5檔案不合要求,可以指定一個模板,模板檔案如果不存在,會報錯,預設是在專案根目錄下找模板檔案,才模板為樣板,將打包的js檔案注入到body結尾處
    inject:'body', // true|body|head|false,四種值,預設為true,true和body相同,是將js注入到body結束標籤前,head將打包的js檔案放在head結束前,false是不注入,這時得要手工在html中加js
}
module.exports = {
    entry: './src/main', //main.js中的js可以省略,前面的./不能省
    output:{
        filename:'./dist/[hash]app.js',
        hashDigestLength: 8
    },
    plugins: [new HtmlWebpackPlugin(HtmlWebpackPluginConfig)], //先不配置外掛,看看效果
    devServer: {
      contentBase: path.join(__dirname, "../dist"), //網站的根目錄為 根目錄/dist
      port: 9000, //埠改為9000
      host: '192.168.0.103', //如果指定的host,這樣同區域網的電腦或手機可以訪問該網站,host的值在dos下使用ipconfig獲取 
      open:true, // 自動開啟瀏覽器
      index:'front.html', // 與HtmlWebpackPlugin中配置filename一樣
      inline:true, // 預設為true, 意思是,在打包時會注入一段程式碼到最後的js檔案中,用來監視頁面的改動而自動重新整理頁面,當為false時,網頁自動重新整理的模式是iframe,也就是將模板頁放在一個frame中
      hot:false,
      compress:true //壓縮
    }
}

結合伺服器和html外掛,最後生成的配置檔案如下

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack')
const HtmlWebpackPluginConfig={
    title: 'hello,零和壹線上課堂', // html5檔案中<title>部分
    filename: 'front.html', // 預設是index.html,伺服器中設定的首頁是index.html,如果這裡改成其它名字,那麼devServer.index改為和它一樣
    // 也是 context+template是最後模板的完整路徑,./不能少
    template: './template/daqi.html', // 如果覺得外掛預設生成的hmtl5檔案不合要求,可以指定一個模板,模板檔案如果不存在,會報錯,預設是在專案根目錄下找模板檔案,才模板為樣板,將打包的js檔案注入到body結尾處
    inject:'body', // true|body|head|false,四種值,預設為true,true和body相同,是將js注入到body結束標籤前,head將打包的js檔案放在head結束前,false是不注入,這時得要手工在html中加js
}


module.exports = {
    context: path.resolve(__dirname,'../src'), //D:\03www2018\study\webpack2017\build\src
    entry: './main', //main.js中的js可以省略,前面的./不能省
    output:{
        path:path.resolve(__dirname,'../dist'),
        filename: './[hash]app.js',
        hashDigestLength: 8
    },
    module: {        
        rules: [       

            ]
      },
    plugins: [
        new HtmlWebpackPlugin(HtmlWebpackPluginConfig), // 生成首頁html5檔案,外部外掛需要安裝
        new webpack.DefinePlugin({BJ: JSON.stringify('北京'),}) // 內建外掛,無須安裝,可以理解為它是webpack例項的一個方法,該外掛相當於apache等web伺服器上定義一個常量
    ], 
    devServer: {
      contentBase: path.resolve(__dirname, "../dist"), //網站的根目錄為 根目錄/dist,這個路徑一般與output.path一致,因為html外掛生成的html5頁是放在output.path這個目錄下
      port: 9000, //埠改為9000
      open:true, // 自動開啟瀏覽器,每次啟動伺服器會自動開啟預設的瀏覽器
      index:'front.html', // 與HtmlWebpackPlugin中配置filename一樣
      inline:true, // 預設為true, 意思是,在打包時會注入一段程式碼到最後的js檔案中,用來監視頁面的改動而自動重新整理頁面,當為false時,網頁自動重新整理的模式是iframe,也就是將模板頁放在一個frame中
      hot:false,
      compress:true //壓縮
    }
}

3.3 給首頁加一張圖片

// D:\03www2018\study\webpack2017\src\template\daqi.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>大奇模板</title>
  </head>
  <body>
      <div style="background-color:#eee;font-size:16px;">歡迎來到零和壹線上課堂1234</div>
      <div id='hello'></div>
      <img src='/img/logo2.jpg' data-src='../images/logo.jpg' />  
  </body>
</html>
  • webpack,通過使用file-loader可以將圖片當成一個模組,使用require來匯入,進一步可以使用url-loader將圖片轉成base64-data
  • 使用圖片的場景大致分四種,html檔案中使用src標籤,樣式的background中設定背景,js檔案中元素.innerHTML='<img src="logo.jpg" />'的方式,最後一種是在vue或react等框架中使用,今天要講的是第一種,如何處理html檔案src標籤中的圖片
  • html檔案中圖片的處理有兩種,一種是象正常使用圖片一樣,不打包,但圖片必須放在打包生成檔案目錄下,如./dist/logo.jpg,也就是最後的入口front.html檔案可以讀到的位置,在front.html中使用<img src='./logo.jpg'/>,表示logo.jpg與最後生成的front.html是同級目錄。但實際工作中,往往圖片放在與打包前的html模板檔案一起的,需要將圖片和html模板檔案分別打包到./dist下,這使用html-loader是解決不了的,官網及網上大部分教程講得不是特別清楚,在這裡我詳細講下,這裡就要用到file-loader,否則會報錯Error: Child compilation failed: Module parse failed: Unexpected character '�' (1:0)You may need an appropriate loader to handle this file type.

第1步:安裝html-loader和file-loader,根目錄/cnpm i -D html-loader file-loader
file-loader處理require('./logo.jpg')這種型別,將圖片當成一個js模組
html-loader是將html中src標籤中配置有特定data屬性的圖片,轉為由require的方式來匯入。也就是說,它只是標識為哪些圖片需要由require的方式匯入,但具體require匯入,得需要file-loader外掛,
第2步:在webpack.conf.js中配置這兩個載入器

module: {
        rules: [
        {
            test: /\.html$/, 
            use: {
                loader: 'html-loader',
                options: {
                 attrs: [':data-src']
                }
            }
        },
     {
        test: /\.(png|jpg|gif)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
                //name: '[path][name].[ext]',
                name: '[name]2.[ext]', //最後生成的檔名是 output.path+ outputPaht+ name,[name],[ext],[path]表示原來的檔名字,副檔名,路徑
                //useRelativePath:true,
                outputPath: 'img/' // 後面的/不能少
            }  
          }
        ]
      },
        ]
      },

第3步:在html檔案src標籤中引用圖片
<img src='/img/logo2.jpg' data-src='../images/logo.jpg' /> 
這裡注意,data-src是打包前圖片位置,src是打包後圖片的url

四: 手機或其它電腦訪問該伺服器

實際開發中,需要手機或其它裝置如ipad即時訪問該伺服器
伺服器: 就是開啟webpack-dev-server這臺電腦
其它裝置:下面以同一網路下的手機為例(同一wifi就行)
第一步:配置伺服器


            
           

相關推薦

webpack開始1:安裝webpackwebpack-dev-server

webpack目錄本文參考文件前提條件電腦裝了一個全新的nodejs,最好是LTS版本,舊的nodejs版本可能沒使用webpack的新功能,也可能會丟失一些依賴的包先安裝好淘寶的cnpm,淘寶映象方便些我的安裝環境是win10一:安裝webpack和webpack-dev-server1.準備工作新建專案資

python開始 -- 1篇之環境搭建

接收 window .py 文檔 路徑 很多 教程 編碼 官方   事實上,網絡上有很多相應的教程,本文無意做成文章的粘貼展示板,附上我認為的簡易的安裝詳解: 安裝 Python 環境(編程小白的第一本 Python 入門書),包含了python以及相關的IDE,圖文並茂,

cmd命令列 簡單安裝 Webpack 開始

安裝 Webpack 一 、 在安裝 Webpack 前,你本地環境需要支援 node.js。 windows安裝Node: 32 位安裝包下載地址 : https://nodejs.org/dist/v4.4.3/node-v4.4.3-x86.msi 64 位安裝包

開始--(1)Linux虛擬機器下使用yum安裝gcc

裝了Linux虛擬機器rhel-server-6.4 版本後,在網上看到利用 yum -y install gcc安裝gcc的教程,遇到的各種問題,因為是小白,一步一步詳解如下: 1.首先切換root賬號:  輸入su後輸入密碼, 切換到root $ -> # 2.

Python開始(庫的安裝與初步使用3+習題1.6)

前言: 這個MarkDown編輯器真糾結,我以為上面的儲存到線上草稿箱就是儲存到我的草稿箱,結果MarkDown的草稿箱就只有一個,相當於快取,會自動覆蓋上一個,也就是說不能同時進行兩個筆記。之前寫了好多都沒了,又得從新寫。 正文: 上次的問題解決了,它說

IC卡解密開始1 (也許會有2) 解密工具V2 V3大放送 By:lookyour

中國 tac ... 需要 編輯框 回復 mile gui for 前段時間發了一個破解的PN532工具,詳見 ===========================IC卡解密工具 PN532工具XP 爆破版http://www.52pojie.cn/thread-5978

webpack開始構建多頁項目(mpa)

www .html log targe 環境 分開 webpack 支持 博客 歷時一個星期左右,自己參考webpack官網等,從零開始構建webpack項目。本次的博客也是對前面的webpack項目搭建一文的補充。 在本wepack搭建的項目中,自己實現了下面的這些功

lavarel開始-三彈(路由,控制器,視圖)

clas space web 傳參 route where ace enter ber routes/web.php寫路由 基本路由: Route::get(‘/‘, function () { return view(‘welcome‘);});Route::get

《電子設計開始(2版)》pdf電子書附網盤連結+讀書方法論總結

有效率的讀書方法論 如果我們不是遣詞造句,不是需要對作者的語句一句句斟酌,也不是需要體會優美的語言的話,那麼快速看完一本書並能夠了解書的重要內容,讓書中的內容能夠幫助自己無疑是我們的最終目的。 1.確定讀書的目的,特別是“商務類”書籍。你為什麼會買它?你想從它這裡得到什

Python3爬蟲開始:庫的安裝

   抓取網頁之後下一步就是從網頁中提取資訊。提取方式有很多種,可以利用正則表示式進行提請,但是相對而言比較麻煩繁瑣。現在有很多強大的解析庫供我們使用,如lxml,Beautiful Soupp,pyquery等。本節對其安裝進行介紹。 lxml的安裝     lxm

webpack開始構建專案之rem問題(三)

使用webpack解決px轉rem的自適應問題 現在的專案配置已經可以正常執行 接下來我們要考慮下一個問題,由於VUE主要適用於移動端,所以我們需要一個自適應方案 由於這是一個大眾需求的剛需方案,所以我們大可不必自己手動去寫JS程式碼,重複造輪子 那麼我

Android安卓開發開始 共43

目錄2 x4 S: _& o2Z" m0 E├─[Android開發從零開始].01.Android開發環境搭建 .mp4- T$ d7 w- g* N$ C├─[Android開發從零開始].02.模擬器的使用 .mp4├─[Android開發從零開始].03.第一個Android程式 .mp4├─

萌新web前端開始1)——計算機入門

    前言:這是一個萌新從零開始的學習之路,與大家分享自己的看法與見解,還請指出錯誤與遺漏點方便改正。     1.認識計算機。     計算機語言常見的有C,PHP,Ruby,Java,C#,Basic,JS,C++等,這裡我用到的是C#語言,用到的軟體是VisualStudio 2013版本。當用V

js 開始4天

前面我們講了js的用法,函式,輸出,今天我們講一下他的一些基本語法當然之前也有涉獵,如果有細心地朋友應該可以發現。 javascript中宣告一個變數是有一個關鍵詞叫 var 當然宣告不同的東西賦值是不一樣的。 var length

開始搭建屬於你的React/redux/webpack腳手架

大家好,我是蘇南,今天要給大家分享的是<<我的react入門到放棄之路>>,當然,也不是真的放棄啦~~哈哈,這篇部落格原本是從17年初寫的,一直沒有在csdn釋出,希望今天不會太晚,望各位老司機勿噴! 上圖可以找亮點,留言答對有獎哦~

開始學習Memcached之安裝&set命令測試

    Memcached是一個自由開源的,高效能,分散式記憶體物件快取系統,是一種基於記憶體的key-value儲存,用來儲存小塊的任意資料(字串、物件)。這些資料可以是資料庫呼叫、API呼叫或者是頁

Hadoop開始--Centos作業系統的安裝

學習Hadoop需要一個學習,測試執行環境,今天就讓我們從安裝虛擬機器開始。 一、安裝環境和工具: 1.windows 10 作業系統 2.VMware Workstation 10 虛擬機器 Centos6.5 系統映象 二、步驟概述 第一步:在Windows系統下安裝

odoo12開始:一、安裝odoo執行環境(windows10)

前言       鑑於好多朋友說沒有mac電腦,windows開發其實也差不了多遠,只是個人習慣問題,而且吧,windows的電腦其實配環境也挺快的其實,我在這裡再稍微補一個比較簡單的windows環境部署,希望可以對朋友們有一些幫助。 在windows10上安裝odoo12

驅動開發 —— 開始1) 配置vs20xx+wdkxx+winX環境並附錄常見問題解決方式

網上教程很多、如何去安裝如何去配置 但是也有些坑感覺並不是那麼的完善 wdk+vs下載連結:https://docs.microsoft.com/zh-cn/windows-hardware/drivers/download-the-wdk 只要wdk版本與sdk版本對應就行,不用在意是vs20xx 我這邊以

開始玩轉JMX(一)——簡介Standard MBean

pos cor csdn comm art order clas post tex 從零開始玩轉JMX(一)——簡介和Standard MBeanJMX超詳細解讀 參考資料JMX整理JMX簡介http://blog.csdn.net/DryKillLogic/articl