網頁前端自動化工具 – Grunt
今天為各位介紹的是一個前端工程師所使用的自動化工具「Grunt」,為何我們要使用這個工具呢?其實使用這個工具的原因有很多,因為他的擴充模組(Plugin)也很多,不過今天馬老師從自動最小化(Minify)的角度來介紹這個工具該如何使用。
一般來說前端網頁開發不外乎HTML、CSS、Javascript這三種語法,而在開發完成之後,為了要節省流量,我們可能會把這三個檔案壓縮後再上傳到網站伺服器上,何謂壓縮請參考下圖:
從上面的檔案可以觀察出在開發時我們為了閱讀的便利,常常會利用註解、空白…等來輔助,但真正發佈出去這些東西卻不是必要的,甚至在開發的時候我們為了方面會把CSS或JS拆成好幾個檔案,但發佈之後卻希望可以合併,但如果需要人工來做這件事,可想而知會有多麻煩,這個時候Grunt就會發揮效用了,設定好之後只要一個指令,他就可以幫我們做好這些動作,接下來就來看看該如何使用吧。
首先Grunt是一個基於node.js下的應用程序,所以必須先安裝node.js,安裝的部分並不難,從官網下載後直接執行安裝即可。
接下來可以參考Grunt網站中Getting Started的單元,或是跟著以下(以Windows為案例)的方式進行Grunt的安裝。
- 打開「命令提示字元」。
- 輸入「npm install -g grunt-cli」。
- 接下來就可以準備網頁專案資料夾了,如下圖所示,我的網頁專案資料夾簡單分成兩個:
- src:所有開發檔案
- public:發佈至網路上的檔案
- 這樣準備的目的應該很清楚,就是希望在src資料夾內以自己最習慣、最方便閱讀的方式來開發,而開發完畢之後可以把壓縮的檔案轉至public資料夾,上傳到伺服器上。
有關於網頁內容開發的部分,本篇文章就省略,所以可以看到上面圖檔中我已經準備好了HTML、CSS、JS各一個,直接進入利用Grunt開始做自動最小化的部分。
- 使用Grunt時,必須在網站根目錄建立兩個檔案:
- package.json:Grunt的專案設定檔,其中可以包含專案名稱、作者、版本,所需要使用的Plugin…等,可以參考下面我的檔案。
- Grunt.js:Grunt的執行腳本,以本案例來說就是要去哪個資料夾,壓縮哪些檔案後存放在哪邊,需在本檔案中指定。
{ "name": "gruntTest", "version": "0.1.0", "author": "Stanley Ma", "devDependencies": { "grunt": "~0.4.5", "grunt-contrib-htmlmin": "~0.4.0", "grunt-contrib-cssmin": "~0.13.0", "grunt-contrib-uglify": "~0.9.2" } }
以上面的package.json檔案來說,定義了專案名稱、作者、版本以及所需要使用的Grunt版本(撰文時Grunt穩定版為0.4.5)和Plugin列表,因為開頭有提到,本案例以最小化的角度來介紹Grunt,所以用到的三個Plugin分別為:
- grunt-contrib-htmlmin:最小化HTML檔。
- grunt-contrib-cssmin:最小化CSS檔。
- grunt-contrib-uglify:最小化JS檔。
- 接下來利用Grunt的專案設定檔來安裝所需要的Grunt和各個外掛,利用「命令提示字元」進入網頁專案的根目錄,輸入「npm install」,他就會在專案資料夾中安裝好所有需要的Plugin。
- 接下來就要開始準備撰寫Grunt.js的執行腳本,大家可以參考我的專案檔案寫法:
module.exports = function (grunt) { grunt.initConfig({ htmlmin: { Target: { options: { removeComments: true, collapseWhitespace: true, removeEmptyAttributes: true, }, files: { 'public/index.html': 'src/index.html', } } }, cssmin: { target: { files: { 'public/index.css': 'src/index.css' } } }, uglify: { target: { files: { 'public/index.js': 'src/index.js' } } } }); grunt.loadNpmTasks('grunt-contrib-htmlmin'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['htmlmin', 'cssmin', 'uglify']); };
這樣的寫法會讓Grunt把在src裡面的三個檔案,分別壓縮後複製一份到public的資料夾中,確定資料夾和檔案無誤之後,繼續下一步動作。
- 利用「命令提示字元」進入網頁專案的根目錄,輸入「grunt」之後,出現以下的畫面表示成功。
- 本案例利用三個Grunt的Plugin完成,分別是:「grunt-contrib-htmlmin」、「grunt-contrib-cssmin」、「grunt-contrib-uglify」,其實這三個外掛都有一些其他的參數,另外也可以進行多檔案的批次轉換以及檔案合併…等等功能,建議有需要的同學可以到Plugin各自的網站上去看看使用方式。
附帶一提,一開始就有提到關於Grunt自動化的Plugin非常多,本文僅用到了三個,這裡有Plugin的列表,對這方面有興趣的同學們也歡迎到網站上看更多相關的自動化功能。
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали ремонт кофемашин philips, можете посмотреть на сайте: ремонт кофемашин philips в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Introducing to you the most prestigious online entertainment address today. Visit now to experience now!
Сколько стоит диплом высшего и среднего образования и как его получить?
generic sildenafil cheap viagra Cheap generic Viagra
buy Viagra over the counter: buy viagra online – buy Viagra over the counter
https://fastpillseasy.com/# ed prescription online
купить аттестат об образовании
County Vintage Postcard & Paper Show.
обзор процессоров обзор процессоров .
Understanding Convex Finance
Convex Finance is an innovative platform designed to enhance yield farming in the decentralized finance (DeFi) space. It allows users to maximize their rewards without the need for technical expertise.
What is Convex Finance?
Convex Finance is a DeFi platform that builds on top of , optimizing the way liquidity providers and stakers can earn rewards. By using Convex, users can increase the efficiency and profitability of their investments.
convex fi
Key Features of Convex Finance
Enhanced Rewards: Users can earn boosted rewards on their staked assets by utilizing the Convex platform.
Decentralized and Secure: Built on top of the existing Curve protocol, ensuring a high level of trust and security.
User-Friendly Interface: Designed to be easy for both new and experienced DeFi users to navigate.
Why Choose Convex Finance?
There are several compelling reasons to choose Convex Finance for your yield farming needs. Whether you’re new to DeFi or an experienced investor, Convex offers unique benefits:
Higher Yields: By pooling your resources, Convex helps maximize the potential returns on your investments.
Gas Fee Efficiency: Transactions through Convex are optimized to reduce costs, making it a more efficient choice.
Community-Driven: Convex evolves based on user feedback, ensuring that the platform continues to meet the needs of its community.
Getting Started with Convex Finance
Starting with Convex Finance is straightforward:
Visit the .
Connect your compatible crypto wallet.
Select the pools you want to stake in and boost your earnings.
For more detailed instructions, referring to the section will provide deeper insights and troubleshooting support.
Conclusion
Convex Finance revolutionizes the way users interact with DeFi, offering enhanced yields while maintaining a focus on security and simplicity. By leveraging the capabilities of Convex, investors can confidently optimize their yield farming strategies.
Boost Your Earnings with Convex Finance Staking
Are you looking to maximize your returns on cryptocurrency investments? Discover the potential of Convex Finance Staking today. This innovative platform offers you the opportunity to earn more by staking popular tokens like CRV, achieving enhanced yields while gaining additional benefits.
What is Convex Finance?
is a cutting-edge decentralized finance (DeFi) protocol that optimizes returns for Curve Finance users. It allows liquidity providers and CRV stakers to earn trading fees, boosted CRV, and take part in Convex liquidity mining.
Why Choose Convex Staking?
Here’s why Convex Finance should be your go-to platform for staking:
Boosted Yields: Earn higher returns by leveraging your CRV tokens and engaging in liquidity mining.
No Withdrawal Fees: Enjoy the flexibility to withdraw your funds without incurring additional costs.
Rewards and Bonuses: Benefit from various incentives, including platform rewards and additional bonuses for loyal stakers.
How to Start Staking on Convex Finance
Follow these simple steps to start maximizing your crypto profits with Convex Finance:
Connect Your Wallet: Use a compatible wallet like MetaMask to link your account to the platform.
Stake Your CRV: Deposit your CRV tokens into Convex to start earning boosted rewards.
Claim Your Rewards: Monitor your earnings and claim your rewards at your convenience.
Explore More Benefits
Aside from staking, Convex Finance offers a unique opportunity to participate in liquidity pools and yield farming initiatives. These options provide you with multiple avenues to enhance your total returns on investments.
Start Staking Today
Visit the official website to learn more about which pools and strategies offer the best returns. Take action today and secure your financial future with Convex Finance’s powerful staking solutions.
Understanding Convex Finance: Boost Your DeFi Earnings
As decentralized finance (DeFi) continues to grow, Convex Finance emerges as a powerful tool for users looking to optimize their Curve Finance (CRV) earnings. Whether you’re a seasoned crypto enthusiast or a newcomer, understanding how Convex Finance works can significantly enhance your income from DeFi investments.
What is Convex Finance?
Convex Finance is a platform that allows liquidity providers (LPs) and CRV stakers to earn higher returns without locking CRV. It achieves this by leveraging specific tokenomics to maximize yield earnings for users, while simplifying the staking process.
How Convex Finance Works
Here’s a breakdown of how Convex Finance operates:
Increased Yield: Convex offers LPs additional rewards on top of the incentives already provided by Curve Finance. This maximizes your DeFi returns.
Platform Flexibility: Unlike traditional staking, Convex Finance enables users to stake either LP tokens or CRVs without enduring long lock-up periods.
Reward Distribution: Participants earn not just from Curve rewards but also receive a share of fees distributed by the platform, further increasing potential earnings.
Benefits of Using Convex Finance
There are several reasons to consider using Convex Finance:
Efficient Yield Optimization: Convex Finance combines yields from multiple sources, providing a streamlined way for users to maximize their earnings.
Lower Commitment: Users can earn rewards without the need for long lock-up periods, maintaining greater liquidity and flexibility.
Community Support: With an active community and ongoing development, Convex Finance regularly updates its platform features to ensure high performance and security.
Getting Started with Convex Finance
To begin using Convex, you’ll need to connect a compatible crypto wallet and deposit your Curve LP tokens. Once connected, you can decide on the best strategy for your investment needs, benefiting from the enhanced yields available on this innovative DeFi platform.
Overall, Convex Finance represents an evolving landscape in decentralized finance, offering a compelling option for maximizing CRV earnings with minimal staking constraints. Explore this platform to leverage its full potential and take advantage of the thriving DeFi ecosystem.
Desyn Protocol
The Desyn Protocol: An Overview
The Desyn Protocol is a cutting-edge framework designed to enhance blockchain technology by offering a scalable and more secure ecosystem. As the demand for decentralized applications grows, the need for efficient protocols becomes crucial. Desyn addresses these needs with a unique approach, providing developers and organizations with the tools to build and manage decentralized systems with enhanced capabilities.
desyn
Core Features of Desyn Protocol
Scalability: The protocol integrates advanced scalability solutions, allowing for increased transaction throughput and reduced latency.
Security: By utilizing state-of-the-art cryptography, Desyn ensures that transactional integrity and data protection are maintained.
Flexibility: Desyn’s modular architecture enables seamless adaptability to various use cases in the blockchain sector.
Applications and Benefits
The Desyn Protocol is versatile, finding applications across different sectors that require blockchain solutions. In finance, it aids in creating smart contracts that bring efficiency and transparency to financial transactions. In supply chain management, Desyn can enhance traceability and accountability from production to distribution. The healthcare industry benefits from secure, immutable record keeping, ensuring both data integrity and patient privacy.
With its emphasis on scalability and security, Desyn reduces resource consumption while optimizing performance, thus driving down operational costs. The flexibility of its architecture supports rapid deployment and integration with existing systems, providing a strategic advantage to businesses looking to transform digitally.
Moreover, developers benefit from the open-source nature of the protocol, which encourages community involvement and continuous innovation. Desyn’s approach promises to lower barriers to entry for startups and established companies alike, fostering a vibrant ecosystem of development.
Conclusion
In conclusion, the Desyn Protocol represents a significant advancement in blockchain technology by combining scalability, security, and flexibility. Its wide range of applications and benefits make it a preferred choice for various industries seeking to leverage blockchain’s transformative power. As the landscape of decentralized technology evolves, Desyn is poised to play a pivotal role, offering solutions that are innovative, efficient, and secure. The protocol’s commitment to enhancing user experience and enabling strategic growth makes it a valuable asset in the digital transformation journey.
вывод из запоя дешево вывод из запоя дешево .
вывод из запоя наркология вывод из запоя наркология .
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали ремонт кофемашин melitta сервис, можете посмотреть на сайте: ремонт кофемашин melitta в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
http://fastpillsformen.com/# Cheap Sildenafil 100mg
Cheap Cialis: MaxPillsForMen.com – buy cialis pill
viagra without prescription Cheap generic Viagra over the counter sildenafil
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали ремонт кофемашин neff сервис, можете посмотреть на сайте: ремонт кофемашин neff в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
рейтинг игровых процессоров https://topcpu.ru .
сравнение процессоров intel https://topcpu.ru .
вывод из запоя в ростове вывод из запоя в ростове .
вывод из запоя срочно ростов вывод из запоя срочно ростов .
Welcome to CBridge: Your Gateway to Cross-Chain Transactions
In the rapidly-evolving world of cryptocurrencies, CBridge stands out as a powerful solution for seamless cross-chain transfers. If you are new to the concept, or simply looking to enhance your crypto experience, CBridge offers a robust platform that ensures fast, cost-effective, and secure transactions across multiple blockchain networks.
[url=https://web-cbridge.com ]cbridge[/url]
What is CBridge?
CBridge is a revolutionary bridge infrastructure designed to facilitate transfers of cryptocurrencies across different blockchain networks. By leveraging the latest in blockchain technology, CBridge allows users to seamlessly move their digital assets between diverse ecosystems without the complexities often associated with such processes.
Key Features of CBridge
High-Speed Transactions: CBridge ensures that cross-chain transfers are completed as quickly as possible, reducing waiting times significantly.
Cost-Effective Solutions: Enjoy lower transaction fees compared to traditional bridges, making it an economical choice for all users.
Security and Privacy: With enhanced security protocols, CBridge maintains the integrity of transactions and protects user data.
User-Friendly Interface: An intuitive platform that simplifies navigation, making it accessible even to beginners.
How Does CBridge Work?
The process is straightforward: users initiate a transaction from their preferred blockchain, select the destination network and currency, and confirm the transfer. CBridge handles the rest, ensuring the digital assets are converted and securely transmitted to the target blockchain.
Benefits of Using CBridge
CBridge not only simplifies the process of moving assets but also opens opportunities for users to explore diverse blockchain applications. Whether you are a trader, investor, or a blockchain enthusiast, CBridge offers a strategic advantage by fostering a truly interconnected crypto ecosystem.
Conclusion
In a world where flexibility and connectivity are key, CBridge offers the optimal solution to unlock new potentials in cross-chain transactions. Its commitment to speed, cost-efficiency, and security makes it an invaluable tool for anyone engaged in the cryptocurrency space.
вывод из запоя круглосуточно ростов вывод из запоя круглосуточно ростов .
вывести из запоя анонимно вывести из запоя анонимно .
выведение из запоя ростов на дону выведение из запоя ростов на дону .
вывод из запоя наркология вывод из запоя наркология .
Как получить диплом техникума с упрощенным обучением в Москве официально
Welcome to Bungee Exchange
In the dynamic world of cryptocurrency, the ability to exchange currencies securely and efficiently is crucial. Bungee Exchange offers a seamless platform that caters to both beginners and experienced traders alike.
bungee exchange
Why Choose Bungee Exchange?
Bungee Exchange stands out as a top choice for currency swaps due to its:
User-Friendly Interface: Designed with simplicity in mind, the platform allows users to navigate with ease.
Robust Security Measures: Your transactions are protected with state-of-the-art security protocols.
Wide Range of Supported Currencies: Bungee Exchange supports a variety of cryptocurrencies to meet diverse trading needs.
Key Features
Here are some key features that make Bungee Exchange an attractive choice:
Instant Transactions: Benefit from quick processing times that facilitate rapid exchanges.
Competitive Exchange Rates: Receive favorable rates that maximize the value of your trades.
24/7 Customer Support: Access reliable support whenever you need assistance or have queries.
How to Use Bungee Exchange
Getting started with Bungee Exchange is straightforward. Follow these steps:
Sign Up: Create an account by providing your email and setting a secure password.
Verify Identity: Complete the KYC process to ensure safety and compliance.
Select Exchange Pair: Choose the currencies you wish to swap.
Confirm Transaction: Review the details and confirm your trade to initiate the exchange.
Conclusion
Whether you are a seasoned trader or just getting started, Bungee Exchange offers a streamlined platform for effective cryptocurrency swaps. With its emphasis on security, user-friendliness, and efficiency, you can trade with confidence. Discover the potential of Bungee Exchange today and take control of your cryptocurrency transactions with ease.
cheap ed medication: FastPillsEasy – pills for erectile dysfunction online