HexSlicing2021.Team13
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    2
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 課前該用好的 gulp by Sz ###### tags: `Sz` `第四週` `gulp` `2021夏季切版班` - [gulp 環境安裝流程](https://hackmd.io/yWpLNMPRT2yvIR4Zq_idGw?view) :::info - 目前已知 - 有了 gulp,live server 再見 - 有了 gulp,scss 編譯器再見 - 有了 gulp,可縮短 html 縮排(版型管理) - 有了 gulp,不用再自己複製貼上每一頁的 header, footer - 有了 gulp,版本控制更輕鬆(git) - 有了 gulp,原圖拖垮網速悲歌再見(圖片壓縮) - 有了 gulp,js 不同瀏覽器的相容性問題再見 ::: ## gulp 環境設置 ### 一台電腦做一次 ::: info :::spoiler 全域安裝 1. 確認是否安裝 [Node.js](https://nodejs.org/en/) (這邊省略安裝步驟) ``` node -v ``` 2. 安裝 gulp (失敗請參考下面一行) ``` npm i gulp@4 -g ``` #### 失敗的話,用管理員權限安裝(限mac) ``` sudo npm i gulp@4 -g ``` 3. 檢查是否安裝好 gulp ``` gulp -v ``` ![](https://i.imgur.com/HIqPwuz.png) 類似這樣即可 ::: ### 一個資料夾做一次 :::warning 你知道你現在在哪嗎? ![](https://i.imgur.com/uCiA2lV.png) 看這行,每次輸入指令都會跳出來 每次都應該要意識到在哪 cd 的指令會改變路徑 可以額外開 terminal 去觀察變化 ::: 1. [下載資料夾](https://github.com/hexschool/web-layout-training-gulp),更改成想要的專案名稱 #### 在該資料夾 2. 在該資料夾安裝 plug-in ``` npm install ``` 3. 在該資料夾執行 gulp,會跳出瀏覽器,即時監看 ``` gulp ``` 4. terminal 停止監看 ``` ctrl + C // 不是 command + C ``` 之後一樣打 `gulp` 都可以叫回來,不用擔心 5. 來開始建置 git 囉 ## git 確認電腦有沒有安裝 git ``` git ``` ### 對該資料夾 1. 初始化,會產生 .git 隱藏資料夾 ``` git init ``` :::success #### 程式端更新(到這裡只有本機喔) 2. 讓 git 關愛所有檔案 ``` git add . ``` 3. 容易焦慮就檢查一下 git 有沒有真的關愛到大家,沒有紅字就可以繼續 ``` git status ``` 4. 有的話就提交囉 ``` git commit -m "輸入提交訊息" ``` 5. 再焦慮的檢查一下有沒有成功提交 ``` git log ``` 以上只有在本機內部做版本控制,但想要上傳到網路上的話,就要繼續往下做囉! ::: ### 連上 github 遠端數據庫 1. github 上創新的 repository 2. 獲取網址 ``` git remote add origin <這裡貼入 github 給的網址> ``` 3. 焦慮的檢查一下有沒有真的連上遠端 - 有的話會顯示這個遠端數據庫的暱稱,暱稱就是上段預設 `origin` 的部份 - 沒有的話檢查一下網址有沒有打錯 ``` git remote ``` 4. 選擇分支(這邊還沒有很懂) ``` git branch -M main ``` 5. (僅限第一次)推上去 ``` git push -u origin main ``` :::success 6. (第二次開始)推上去 ``` git push ``` ### 遠端數據庫 客戶端更新 1. 生產模式(還沒有很懂) ``` gulp build ``` 2. gh-pages(給客戶端演示用) 建置,也會設定好 github pages,這段要給他耐心與愛心 ``` gulp deploy ``` 3. 檢查 github > setting > github pages > source 有沒有對,改完也要有耐心與愛心 4. github pages 給你的網址就是你的展示畫面囉!一樣要給他耐心與愛心 ::: :::success **綠色框框的內容,每次上傳更新都要做** ::: ## 編譯? 編譯就像翻譯一樣,在溝通的雙方語言不同時 就需要進行一個語言轉換的過程 我們寫程式時也一樣,也很容易遇到我們寫的語言,跟處理的軟硬體,懂的語言不同的狀況 這時候中間的轉換就會需要一個類似翻譯的動作 這裡就可以先簡單理解為編譯囉 ## 學到的 gulp 編譯 gulp 整合了很多個原本往往要很多工具才能做到的事 - SCSS 是一個很好管理的 CSS 寫法,但瀏覽器不懂 - layout 的管理不想手動複製貼上,但瀏覽器也看不懂 但瀏覽器是讀不懂的 - 圖片未經處理,檔案巨大 - js 常常每個瀏覽器看起來不一樣 在 gulp 裡面,他 layout, scss, 圖片壓縮, js 兼容的管理 都一併幫你完成囉! ## 資料夾結構 - dist - 編譯後的結果 - **不要動** - app:撰寫資料的位置 - assets:HTML, CSS, JS, 圖檔影片等等放這,不要改名稱,以後可能會遇到會叫做 public 的 - script:gulp 幫你處理相容問題 - style:gulp 幫你編譯 - sass - images::gulp 幫你壓縮省流量 - index.html:需要新增新頁面的話,複製這個檔案去改 - gulpfile.js - enbOptions.js:路徑,可查看輸出的路徑,若要更改路徑要記得 `ctrl+C` 關閉後,`gulp` 重開 ## 新增新頁面 複製 index.html 去改名稱,如果要監看該頁面,在瀏覽器網址尾段加上該檔名 ### HTML 結構 定義 layout 格式,可以對進行共通設定 ``` --- title: <title> // head 裡面那個 title 標籤 layout: ./app/layout.ejs // 共同版型, header, footer 終於幸福ㄌ engine:ejs // 使用的樣板語言,跟我們所學的內容很像 current:index // 暫時不動囉 --- <body 內容> ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully