網頁前端自動化工具 – 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的列表,對這方面有興趣的同學們也歡迎到網站上看更多相關的自動化功能。
i thought about this MetaMask Download
click here for more info Metamask Extension
click resources MetaMask Download
click to read MetaMask Download
click resources Metamask Extension
he has a good point MetaMask Download
pop over to this web-site Metamask Extension
redirected here MetaMask Download
Optimize Your Crypto Trading with TraderJoeXyz
In the dynamic world of cryptocurrency, having the right tools at your disposal can make all the difference. Enter TraderJoeXyz, a cutting-edge platform designed to maximize your trading potential. By leveraging TraderJoeXyz, traders gain access to a multitude of features that cater to both beginners and seasoned professionals. Let’s explore how TraderJoeXyz can enhance your crypto trading journey.
traderjoexyz
Features of TraderJoeXyz
The TraderJoeXyz platform is packed with robust features aimed at simplifying and optimizing cryptocurrency trading:
Advanced Trading Interface: The user-friendly interface is equipped with powerful tools to execute trades efficiently.
Comprehensive Analytics: Gain insights with detailed analytics and customizable charts for better decision-making.
Secure Wallet Integration: Seamlessly manage your crypto assets with integrated security measures.
Automated Trading Bots: Use AI-driven bots to enhance your trading strategy with automated buy and sell actions.
Benefits of Using TraderJoeXyz
Here are some of the benefits you can expect when using TraderJoeXyz:
Increased Efficiency: With streamlined processes and intuitive design, traders can execute trades faster than ever.
Greater Profit Potential: Advanced tools and analytics help you identify profitable trading opportunities.
Reduced Risk: Implementing secure wallet integrations and automated bots can help mitigate risks associated with trading.
Enhanced Trading Experience: A seamless interface paired with powerful tools ensures an exceptional trading journey.
Join the TraderJoeXyz Community
TraderJoeXyz is more than just a platform; it’s a community of crypto enthusiasts and experts. Joining this community provides access to shared knowledge, support, and collaboration opportunities. To become part of this thriving ecosystem, simply and start exploring the world of crypto trading today.
By choosing TraderJoeXyz, you’re not just trading—you’re transforming your crypto experience. Get started and make the most of your cryptocurrency assets.
denemebonusuverensiteler25: yat?r?ms?z deneme bonusu veren siteler – denemebonusuverensiteler25
вывод из запоя в стационаре анонимно вывод из запоя в стационаре анонимно .
вывод из запоя цены сочи [url=vyvod-iz-zapoya-sochi24.ru]vyvod-iz-zapoya-sochi24.ru[/url] .
вывод из запоя в сочи вывод из запоя в сочи .
I blog often and I truly appreciate your content. This great article has really peaked my interest. I’m going to bookmark your blog and keep checking for new details about once a week. I subscribed to your RSS feed too.
en guvenilir casino siteleri: Casino Siteleri – Casino Siteleri
вывод из запоя на дому сочи вывод из запоя на дому сочи .
запой стационар запой стационар .
запой стационар запой стационар .
выведение из запоя в сочи выведение из запоя в сочи .
Consumers may attempt to “lowball” you because you are saving money on a sales fee.
вывод из запоя сочи вывод из запоя сочи .
Discover Stargate Finance: Your Gateway to DeFi
In the rapidly evolving world of decentralized finance (DeFi), Stargate Finance stands out as a reliable platform for decentralized transactions and yield optimization. Let’s explore how Stargate Finance can enhance your financial strategies.
stargate fi
Why Choose Stargate Finance?
Stargate Finance offers a comprehensive suite of tools designed to facilitate seamless and secure transactions. Here’s why you should consider integrating Stargate Finance into your DeFi experience:
Seamless Cross-Chain Transactions: Facilitate instant and smooth transactions across multiple blockchain networks without the hassle of traditional exchanges.
High-Performance Liquidity Pools: Access a wide range of liquidity pools to optimize your yield farming strategies and maximize returns.
Secure Protocols: Enjoy peace of mind with top-tier security measures designed to protect your assets and data.
Features that Enhance Your DeFi Experience
Stargate Finance uniquely positions itself by offering features that cater to both novice and veteran DeFi users:
Intuitive User Interface: Navigate effortlessly through the platform with a user-friendly interface that simplifies complex DeFi operations.
24/7 Customer Support: Get assistance anytime with a dedicated support team available to resolve queries and help optimize your DeFi strategies.
Comprehensive Analytics: Leverage data-driven insights to make informed decisions, tailor your yield farming, and monitor performance.
Getting Started with Stargate Finance
Ready to dive into the world of DeFi with Stargate Finance? Here’s a quick guide to get you started:
Visit the and create your account.
Connect your crypto wallet to begin accessing the features.
Explore liquidity pools and start yield farming to optimize your returns.
With these resources, you can securely and efficiently manage your decentralized financial strategies.
Conclusion
Stargate Finance empowers you to confidently participate in the DeFi landscape, offering secure, efficient, and user-friendly solutions for the modern investor. Discover what it means to have a true gateway to financial freedom and innovation with Stargate Finance.
For more information and to get started today, .
Understanding Stargate Finance Token
The Stargate Finance Token is an integral part of the blockchain ecosystem, especially for those involved in decentralized finance (DeFi). As a bridge to seamless blockchain transactions, it plays a crucial role in enhancing interoperability across different networks.
Key Features of Stargate Finance Token
Stargate Finance Token stands out in the DeFi space for several reasons. Here are its key features:
Interoperability: Facilitates cross-blockchain transactions with ease.
Scalability: Designed to handle a large volume of transactions.
Security: Incorporates advanced security protocols for secure transfers.
Liquidity Pools: Offers attractive opportunities for liquidity providers.
Benefits of Using Stargate Finance Token
Using the Stargate Finance Token provides several benefits to investors and users:
Cost Efficiency: Reduces transaction fees compared to traditional methods.
Speed: Transfers are quick, minimizing waiting times.
Investment Potential: Opportunity for profitable returns through staking and liquidity.
Innovation: Continuously updates to incorporate the latest in blockchain technology.
How to Get Started with Stargate Finance Token
Getting started with Stargate Finance Token is straightforward:
Visit a reputable that lists Stargate tokens.
Create an account and complete any necessary verification.
Deposit funds into your account via fiat or cryptocurrency transfer.
Purchase Stargate Finance Tokens from the exchange market.
Consider joining liquidity pools or staking to maximize your returns.
Inconveniences like shivering outside in the cold to enjoy a smoke may actually contribute to some smokers’ desires to quit.
guvenilir slot siteleri slot casino siteleri slot oyunlar?
deneme bonusu veren siteler: yat?r?ms?z deneme bonusu veren siteler – yeni deneme bonusu veren siteler
Introducing Velodrome Finance: Maximize Your Crypto Yields
In the rapidly evolving world of decentralized finance (DeFi), Velodrome Finance emerges as a robust platform for enthusiasts looking to enhance their crypto yield returns. This guide will walk you through the essentials of Velodrome Finance and how you can benefit from its features.
velodrome fi
Why Choose Velodrome Finance?
Velodrome Finance stands out as a comprehensive DeFi protocol designed specifically for liquidity providers. Its innovative approach focuses on maximizing rewards while maintaining efficient and secure trading mechanisms. Here’s why it’s capturing the attention of the DeFi community:
Efficient Token Swaps: Velodrome offers seamless and cost-effective token swapping capabilities.
Liquidity Pools: Participants can provide liquidity to various pools, optimizing their earning potential.
Yield Optimization: With advanced strategies, Velodrome helps users achieve superior returns on their investments.
Secure Protocol: Security is a top priority, and Velodrome utilizes cutting-edge technology to protect user assets.
Getting Started with Velodrome
Embarking on your journey with Velodrome Finance is straightforward. Here’s a step-by-step guide to help you dive into the platform:
Create a Wallet: To engage with Velodrome, you first need a compatible crypto wallet.
Connect Your Wallet: Visit and securely link your crypto wallet.
Explore Liquidity Pools: Browse through available pools and decide where to allocate your assets for optimal returns.
Stake and Earn: Once you’ve funded a pool, begin staking and watch your earnings grow as you benefit from trading fees and incentives.
Community and Support
Velodrome Finance boasts a vibrant community ready to assist users at any step. Whether you’re a seasoned DeFi user or a newcomer, you can find guidance and support from community forums and dedicated customer service.
Conclusion
With its focus on maximizing crypto yield, Velodrome Finance is a compelling choice for anyone looking to delve deeper into the DeFi space. From efficient token swaps to robust security measures, it offers a complete ecosystem for those eager to optimize their returns. Visit the official site and start your journey towards enhanced financial growth.
Admiring the time and energy you put into your blog and in depth information you provide. It’s nice to come across a blog every once in a while that isn’t the same outdated rehashed information. Wonderful read! I’ve saved your site and I’m adding your RSS feeds to my Google account.
https://slovo-pacana.info/
What is Uniswap?
Uniswap is a decentralized exchange (DEX) protocol built on the Ethereum blockchain. It enables direct peer-to-peer cryptocurrency transactions, allowing users to trade coins without intermediaries. This makes it a cornerstone of the Decentralized Finance (DeFi) ecosystem.
uniswap app
Benefits of Using Uniswap
Uniswap offers several advantages over traditional, centralized exchanges:
Decentralization: Users maintain control of their funds, minimizing the risk of hacking or fraud associated with central exchanges.
Liquidity Pools: Uniswap uses automated liquidity pools instead of traditional order books, enabling seamless and efficient trading.
Open Access: Anyone with an Ethereum wallet can trade on Uniswap, facilitating financial inclusivity.
No Registration: Trade instantly without creating an account or passing through identity verification processes.
How to Use Uniswap
Getting started with Uniswap is simple and intuitive. Follow these steps:
Create and fund an Ethereum wallet if you don’t have one. Some popular options include MetaMask, Trust Wallet, and Coinbase Wallet.
Connect your wallet to the Uniswap platform by navigating to their website and initiating the connection process.
Choose the tokens you wish to trade. Always ensure you are aware of the gas fees involved in the transaction.
Initiate the swap and confirm the transaction in your wallet. Your new tokens will be available once the transaction is confirmed on the blockchain.
Security Tips
While Uniswap is a secure platform, it’s crucial to follow best practices to ensure your funds remain safe:
Always ensure you are accessing the legitimate Uniswap website by verifying the URL.
Keep your wallet’s private keys secure and never share them with anyone.
Regularly update your cryptocurrency wallet and browser to prevent vulnerabilities.
Conclusion
Uniswap has revolutionized the way cryptocurrency trading operates by providing a secure, user-friendly, and inclusive platform. Whether you are a seasoned trader or a newcomer to the crypto world, Uniswap offers a powerful tool for navigating the DeFi landscape.
Welcome to PancakeSwap: A Beginner’s Guide
PancakeSwap is a decentralized exchange platform on the Binance Smart Chain, designed for swapping BEP-20 tokens. With its vibrant ecosystem, ease of use, and low transaction fees, it’s become a popular choice among crypto enthusiasts.
pancakeswap finance
What is PancakeSwap?
PancakeSwap is an automated market maker (AMM) that allows users to trade directly from their crypto wallets. There’s no order book involved; instead, trades are made against a liquidity pool. Here’s how you can get started:
How to Use PancakeSwap?
Set Up Your Wallet
First, you need a crypto wallet like MetaMask or Trust Wallet. Ensure your wallet supports BEP-20 tokens.
Connect to Binance Smart Chain
Configure your wallet to connect to the Binance Smart Chain network. Detailed guides are available in your wallet settings.
Purchase BNB
You’ll need BNB (Binance Coin) to cover transaction fees. Buy BNB from a reputable exchange and transfer it to your wallet.
Access PancakeSwap
Visit the official PancakeSwap website and connect your wallet by clicking on the ‘Connect Wallet’ button.
Start Trading
Once connected, you can begin swapping BEP-20 tokens. Choose the tokens you wish to trade and confirm your transactions.
Benefits of PancakeSwap
Lower Fees: Operating on Binance Smart Chain, the fees are more affordable than Ethereum-based exchanges.
Fast Transactions: Experience quick transaction speeds due to the efficiency of BSC.
Yield Farming: Earn rewards by providing liquidity or participating in various farming pools.
Conclusion
PancakeSwap offers a user-friendly approach to trading cryptocurrencies, engaging users with its gamified elements like lotteries and collectibles. Whether you’re a beginner or an experienced trader, PancakeSwap provides an efficient and exciting way to dive into the world of decentralized finance. Always ensure to perform your due diligence before engaging in trading activities.
For more detailed guides and support, visit the .
deneme bonusu veren siteler yeni denemebonusuverensiteler25 deneme bonusu veren siteler yeni