網頁前端自動化工具 – 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的列表,對這方面有興趣的同學們也歡迎到網站上看更多相關的自動化功能。
Welcome to Extra Finance
At Extra Finance, we believe in empowering individuals and businesses with the tools they need to manage their finances more effectively. Whether you are looking to save smarter, invest wisely, or simply manage your expenses better, Extra Finance offers a range of solutions to help you achieve your goals.
extra fi
Why Choose Extra Finance?
Extra Finance stands out for its commitment to customer satisfaction and cutting-edge financial tools. Here are a few reasons why you should consider us:
Comprehensive Financial Solutions: From personal savings plans to business investment opportunities, we cover a wide spectrum of financial needs.
User-Friendly Platform: Navigate through your financial options with ease thanks to our intuitive and straightforward interface.
Expert Guidance: Our team of experienced financial advisors is always ready to assist you in making the best financial decisions.
Services Offered by Extra Finance
Extra Finance is committed to providing a diverse range of services that cater to different financial needs:
Personal Finance Management: Tools and advice to help individuals manage their personal finances, set budgets, and save for the future.
Investment Solutions: Personalized investment portfolios to help you grow your wealth according to your financial objectives.
Loan Products: Flexible and competitive loans tailored to meet your needs.
Retirement Planning: Strategic planning services to ensure your retirement is financially secure and comfortable.
Getting Started with Extra Finance
To join Extra Finance, simply create an account on our platform and begin exploring the numerous financial opportunities available to you. With just a few clicks, you can take control of your financial future.
Remember, financial success is not just about making the right decisions today but about planning for tomorrow. Let Extra Finance be your partner on this journey to financial freedom!
Welcome to Swell Network: Your Gateway to Decentralized Finance
The world of cryptocurrency is rapidly evolving, with new platforms emerging to offer innovative financial solutions. Swell Network stands out as a pioneering force in decentralized finance (DeFi), providing users with unique opportunities to engage with the financial future.
swell network
What is Swell Network?
Swell Network is a blockchain-powered platform that aims to disrupt traditional financial systems. It offers a wide range of DeFi services designed to enhance user autonomy and financial inclusivity. By leveraging blockchain technology, Swell Network ensures secure, transparent, and efficient financial transactions.
Key Features of Swell Network
Decentralization: Operates on a decentralized framework, reducing reliance on traditional financial institutions.
Security: Utilizes cutting-edge security protocols to protect user assets and data.
Transparency: All transactions are recorded on the blockchain, ensuring complete visibility and traceability.
Accessibility: Open to anyone with internet access, promoting global financial inclusivity.
Benefits of Using Swell Network
Adopting Swell Network for your financial activities comes with several benefits:
Reduced Fees: Experience lower transaction fees compared to conventional banking systems.
Greater Control: Manage your funds in real-time without intermediaries.
Innovative Opportunities: Participate in a variety of financial ventures such as liquidity pools and yield farming.
Getting Started with Swell Network
If you’re ready to join the DeFi revolution, getting started with Swell Network is straightforward. First, create your account on the platform, then explore different financial instruments that meet your needs. Swell Network offers comprehensive support and resources to guide new users through the onboarding process.
Stay Informed
In the ever-evolving crypto landscape, staying informed is crucial. Swell Network regularly updates its community with the latest developments and feature releases. Follow their official communication channels such as blogs, newsletters, and social media to stay up-to-date.
Embrace the future of finance today with Swell Network and explore the endless possibilities of decentralized finance. to learn more and start your journey.
Unveiling the Potential of Kelp DAO
In today’s rapidly evolving digital economy, Kelp DAO emerges as a transformative force in the field of decentralized finance (DeFi). By leveraging blockchain technology, Kelp DAO aims to improve governance and promote sustainability.
What is Kelp DAO?
Kelp DAO is a decentralized autonomous organization (DAO) designed to democratize decision-making processes on the blockchain. It serves as a pivotal tool for communities seeking enhanced and a focus on eco-friendly initiatives.
Why Choose Kelp DAO?
Here are several compelling reasons to consider Kelp DAO for your blockchain ventures:
Environmental Sustainability: Kelp DAO incorporates mechanisms that align with environmental conservation goals, making it an eco-conscious choice.
Decentralized Governance: With a robust framework for community-driven governance, participants can actively influence project directions.
Innovation in DeFi: By fostering an environment of innovation, Kelp DAO contributes to the evolving landscape of decentralized finance.
How Does Kelp DAO Work?
Kelp DAO operates through a token-based voting system, where community members hold the power to vote on proposals and influence project decisions. The DAO’s infrastructure ensures transparency and inclusivity, empowering stakeholders.
Getting Involved with Kelp DAO
Joining Kelp DAO is a straightforward process. Interested parties can engage by acquiring Kelp tokens, participating in community discussions, and voting on platform proposals. This involvement not only offers strategic governance participation but also contributes to the broader aim of sustainable development in the digital realm.
The Future of Kelp DAO
The ultimate vision for Kelp DAO is a fully decentralized platform where members collaboratively address global challenges while advancing decentralized financial mechanisms. As the community grows, so does its capacity to influence .
Join Kelp DAO today and become part of a pioneering movement towards a sustainable and decentralized financial future.
slot oyunlar? puf noktalar? az parayla cok kazandiran slot oyunlar? az parayla cok kazandiran slot oyunlar?
slot casino siteleri: az parayla cok kazandiran slot oyunlar? – guvenilir slot siteleri
The Writing is a go-to resource, like a favorite coffee shop where the barista knows The order. Always comforting.
Полезная информация как купить диплом о высшем образовании без рисков
https://denemebonusuverensiteler25.com/# deneme bonusu veren siteler yeni
sweet bonanza slot: sweet bonanza demo oyna – sweet bonanza guncel
Understanding Rhino Technology
Rhino technology represents the forefront of digital finance solutions, offering innovative tools for both consumers and businesses. Designed to streamline processes and enhance user experience, Rhino technology stands out as a pivotal development in the financial world.
rhino bridge
Features of Rhino Technology
Scalability: Rhino technology is built to grow with user needs, supporting both small operations and larger enterprises with ease.
Security: Integration of advanced security protocols ensures that transactions and data are protected from unauthorized access.
User-Friendliness: With a focus on intuitive design, Rhino technology offers an interface that is easy for users of all levels to navigate.
Applications of Rhino Technology in Finance
In the financial sector, Rhino technology plays a crucial role in enhancing efficiency and ensuring compliance with industry standards. It empowers users with tools that simplify complex financial operations, making them more accessible and less time-consuming. Beyond financial transactions, Rhino technology aids in data analysis, helping businesses make informed decisions based on real-time analytics.
In conclusion, Rhino technology is a transformative force in the financial industry. Its ability to provide scalable, secure, and user-friendly solutions positions it as a crucial player in digital finance. As industries continue to evolve, relying on such cutting-edge technology ensures that businesses remain competitive, efficient, and secure.
Good post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. It will always be useful to read through articles from other authors and practice a little something from other websites.
https://millionigrushek.ru/
Understanding Venus Protocol: Your Gateway to DeFi
Venus Protocol has carved a niche in the fast-paced DeFi landscape by offering a one-stop solution for decentralized finance activities. Whether you’re interested in lending, borrowing, or yield farming, Venus provides secure and scalable services on the blockchain.
venus defi
Why Choose Venus Protocol?
The Venus Protocol stands out because:
It operates on the Binance Smart Chain, ensuring fast and cost-effective transactions.
It offers a decentralized lending platform that allows users to earn interest by supplying assets.
The protocol enables borrowing against crypto collateral without the need for a trusted counterparty.
It supports a wide range of crypto assets, providing higher liquidity and flexibility.
Key Features of Venus Protocol
Lending and Borrowing
Venus Protocol facilitates decentralized lending and borrowing with minimal fees, supported by a robust risk management framework. Users can seamlessly supply assets to the protocol and earn interest, or borrow by simply collateralizing their holdings.
Automated Yield Farming
Maximize your returns with Venus Protocol’s yield farming opportunities. By leveraging your assets, you can participate in governance and earn rewards in the form of XVS, Venus Protocol’s native token.
Multi-Asset Support
The platform supports numerous cryptocurrencies, enabling diverse investment strategies and providing a convenient way to gain returns on multiple asset classes.
Getting Started with Venus Protocol
Start your DeFi journey with Venus Protocol by following these steps:
Create a Wallet: Use a compatible wallet like Metamask or Trust Wallet to interface with Venus.
Fund Your Wallet: Transfer crypto assets to your wallet to engage with the Venus Protocol.
Connect and Start Earning: Connect your wallet to the Venus platform and start supplying or borrowing assets.
Venus Protocol is your trusted partner in the decentralized financial ecosystem. With its advanced features and strong community support, it simplifies DeFi for everyone from beginners to seasoned users. Embrace the future of finance with confidence and start exploring the possibilities at .
Getting Started with Quickswap
Quickswap is revolutionizing the way we trade cryptocurrencies by offering a decentralized platform for seamless crypto trading. As a user-friendly decentralized exchange (DEX), Quickswap allows users to swap tokens effortlessly without the need for intermediaries. Here’s a detailed guide to getting started with Quickswap.
quickswap v3
What is Quickswap?
Quickswap is a layer-2 decentralized exchange built on the Polygon network, which is known for its high-speed and low-cost transactions. This platform provides an efficient and secure way to trade a wide range of cryptocurrencies without enduring hefty fees typical of Ethereum-based DEXes.
Why Use Quickswap?
Low Fees: Thanks to the Polygon network, trading on Quickswap is significantly cheaper than on Ethereum-based platforms.
High Speed: Experience fast transaction speeds that enhance user experience and trading efficiency.
User-Friendly Interface: Quickswap’s interface is designed to be intuitive, even for beginners, making it easy to trade cryptocurrencies.
How to Use Quickswap
Set Up a Crypto Wallet: You’ll need a compatible wallet like MetaMask or Trust Wallet. Ensure it’s connected to the Polygon network.
Fund Your Wallet: Purchase or transfer tokens into your wallet for trading.
Visit Quickswap Platform: Navigate to the Quickswap website and connect your wallet. This step is essential to access all features of the platform.
Start Trading: Select the tokens you want to swap. With its simple interface, you can execute trades in just a few clicks.
Tips for Effective Trading on Quickswap
To make the most out of your trading experience on Quickswap, consider these tips:
Keep an eye on the market trends and choose the right time for your trades.
Understand the token pairs and their liquidity status to avoid high slippage.
Regularly update your wallet and security settings to protect your assets.
Conclusion
Quickswap offers a robust platform for trading a wide range of cryptocurrencies efficiently. By leveraging the benefits of the Polygon network, it minimizes delays and costs associated with traditional crypto trading. Whether you’re a beginner or a seasoned trader, Quickswap empowers you to navigate the DeFi space with ease and confidence.
Welcome to Orbiter: Your Gateway to Financial Innovation
In the ever-evolving landscape of finance, Orbiter stands out as a pioneering platform dedicated to providing cutting-edge solutions for modern investors. As we navigate the future of digital assets and decentralized finance, Orbiter remains at the forefront, committed to innovation and accessibility.
orbiter bridge
Why Choose Orbiter?
Orbiter offers unique advantages that set it apart in the financial world:
Decentralized Solutions: Benefit from a trustless environment where transactions are secure and transparent.
Innovative Technologies: Leverage groundbreaking technologies, designed to maximize efficiency and utility.
Community Driven: Engage with a global community that supports and uplifts each other in the financial journey.
Key Features of Orbiter
Orbiter’s platform is rich with features tailored to both new and experienced investors.
1. Smart Investments
Utilize intelligent tools that enable you to optimize your investment strategies. Orbiter’s algorithms are crafted to pinpoint opportunities in both volatile and stable markets.
2. Secure Transactions
Enjoy peace of mind with Orbiter’s advanced security measures. Our platform ensures that each transaction is protected through top-tier encryption and blockchain technology.
3. User-Friendly Interface
Navigate with ease! Our user-friendly design ensures accessibility for everyone, from beginners to seasoned traders.
Join the Orbiter Community
By joining Orbiter, you’re becoming part of a larger movement towards decentralized and democratized finance. Share insights, learn from peers, and grow your financial acumen in the company of like-minded individuals.
Ready to explore the future of finance? Let Orbiter guide your journey towards smarter, more secure, and lucrative investments. Join us today and revolutionize how you approach financial management.
Tackled this hard to understand issue with elegance. I didn’t know we were at a ballet.
The depth you bring to The topics is like diving into a deep pool, refreshing and invigorating.
Unlock Your Financial Potential with Puffer Finance
In an ever-evolving economic landscape, finding the right financial partner is essential for achieving your investment goals. Puffer Finance stands out as a beacon of innovation and stability, offering a plethora of opportunities to enhance your wealth.
puffer fi
Why Choose Puffer Finance?
Choosing the right financial institution is pivotal in ensuring the security and growth of your investments. Here are compelling reasons to partner with Puffer Finance:
Innovative Financial Solutions: Puffer Finance provides cutting-edge options tailored to meet diverse investment needs.
Expert Guidance: Harness the wisdom of experienced finance professionals dedicated to optimizing your portfolio.
Robust Security Measures: Your investments are well-protected, ensuring peace of mind amidst market fluctuations.
Services Offered by Puffer Finance
Puffer Finance prides itself on offering a wide range of services, each designed to cater to specific client needs and financial ambitions. These include:
1. Investment Management
Our thorough investment management services provide strategic planning and execution to enhance your portfolio’s performance.
2. Personal Financial Planning
Whether you are saving for retirement or planning a major purchase, our personal financial planning services are tailored to help you achieve your ambitions.
3. Wealth Preservation Strategies
We offer strategies that not only aim to grow your wealth but also safeguard it against potential risks.
Getting Started with Puffer Finance
Embarking on your financial journey with Puffer Finance is a seamless process. Simply to explore how we can help tailor financial strategies to your individual needs. With Puffer Finance, you are not just investing your money; you are investing in a future laden with possibilities.
Testimonials from Satisfied Clients
Puffer Finance has been a trusted partner for many satisfied clients:
“Thanks to Puffer Finance, I have not only grown my wealth but gained confidence in my financial future.” – Alex T.
“The tailored advice and financial strategies have truly transformed my investment approach.” – Samantha L.
In conclusion, if your goal is to enhance and secure your financial estate, Puffer Finance provides the tools and expertise to guide you through a prosperous journey.
What is Lido Finance?
Lido Finance is a decentralized finance (DeFi) platform that provides simple and efficient solutions for crypto staking. It allows users to stake their digital assets without locking them up, thus maintaining liquidity and flexibility.
lido finance
Why Choose Lido Finance?
Lido Finance provides several benefits to its users:
Liquidity: Unlike traditional staking, Lido issues liquid tokens that can be traded or used within other DeFi applications.
Flexibility: Avoid the rigid locking periods that come with typical staking protocols.
Security: Leverages the security and decentralization inherent in blockchain technology, ensuring your assets are safe.
How Does It Work?
Users can stake their assets via Lido’s platform, which then delegates these assets across a set of trusted validators. In return, users receive staked tokens which represent their staked assets and accrue rewards over time.
Getting Started with Lido Finance
Follow these steps to begin staking:
Visit the Lido Finance website and connect your crypto wallet.
Select the asset you wish to stake, for instance, ETH.
Enter the amount and execute the transaction.
Receive staked tokens that represent your staked amount.
Join the Decentralized Finance Revolution
With Lido Finance, enjoy the benefits of staking without compromising on liquidity and flexibility. Start today and keep your crypto assets working round the clock.
Casino Siteleri guvenilir casino siteleri Canl? Casino Siteleri
The dedication to high quality content shows. It’s like you actually care or something.
Pendle Finance: Unlocking New Opportunities in DeFi
As the world of decentralized finance (DeFi) continues to evolve, Pendle Finance is at the forefront, offering innovative solutions for yield and trading. This platform has quickly become a go-to resource for individuals looking to maximize their crypto investments.
pendle fi
What is Pendle Finance?
Pendle Finance is a DeFi protocol designed to provide enhanced yield management opportunities by leveraging tokenization of future yield. It allows users to trade tokenized yield, offering flexibility and potential for optimized earnings.
Key Features
Yield Tokenization: Convert future yield into tradable assets, enhancing liquidity.
Yield Trading: Enter and exit yield positions at strategic times to capitalize on market conditions.
Multi-Chain Support: Access a wide range of DeFi ecosystems through cross-chain functionality.
Benefits of Using Pendle Finance
Pendle Finance provides numerous benefits to its users, making it a compelling choice for DeFi enthusiasts and investors:
Diversified Investment Options: By tokenizing future yields, Pendle offers a variety of strategies to enhance your investment portfolio.
Market Flexibility: Trade yield tokens freely, allowing for strategic entry and exit points.
Enhanced Liquidity: Tokenization increases the liquidity of yields, offering more opportunities for dynamic financial strategies.
How to Get Started with Pendle
Embarking on your Pendle Finance journey is straightforward. Follow these steps to unlock the potential of yield trading:
Create an Account: Set up a user account on the Pendle Finance platform.
Link Your Wallet: Connect your cryptocurrency wallet to seamlessly manage transactions.
Start Trading: Explore the available yield tokens and start trading to optimize your returns.
Conclusion
In a rapidly changing financial landscape, Pendle Finance stands out by offering innovative solutions aimed at enhancing investment opportunities. Whether you are a seasoned DeFi user or a newcomer, Pendle provides tools and resources to empower your financial growth. Join the community and start unlocking the potential of your investments today!
Welcome to SushiSwap: Your Gateway to Decentralized Finance
SushiSwap is a leading decentralized finance (DeFi) platform that allows users to trade cryptocurrencies directly from their digital wallets. Built on top of the Ethereum blockchain, SushiSwap is designed to offer a seamless, trustless, and secure trading experience.
sushiswap protocol
Key Features of SushiSwap
Here’s what sets SushiSwap apart from other decentralized exchanges:
Swaps: Instantly swap a wide array of tokens without the need for an intermediary.
Liquidity Pools: Provide liquidity to earn rewards from transaction fees and Sushi tokens.
Yield Farming: Stake your tokens and earn additional incentives with high returns.
Governance: Participate in community decision-making processes to shape the future of the platform.
How to Use SushiSwap
Follow these steps to get started on SushiSwap:
Connect Your Wallet: Select a compatible wallet like MetaMask to interact with the platform securely.
Select Tokens: Choose the cryptocurrencies you wish to swap.
Confirm Transaction: Review and confirm your transaction details.
Manage Liquidity: Optionally, add liquidity to pools and earn rewards.
Why Choose SushiSwap?
SushiSwap offers numerous advantages for crypto traders:
Decentralized control ensures your funds are always under your personal control.
Competitive fees and rewards mechanisms encourage active participation.
A diverse range of tokens and pairs expands your trading options.
Join the SushiSwap community now and transform the way you trade using our state-of-the-art platform.
Stay Informed
Stay updated with the latest developments and community news by joining SushiSwap’s social media channels and forums. Unlock the potential of decentralized trading today.
Howdy I am so grateful I found your weblog, I really found you by error, while I was browsing on Yahoo for something else, Nonetheless I am here now and would just like to say cheers for a tremendous post and a all round exciting blog (I also love the theme/design), I don’t have time to go through it all at the moment but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read much more, Please do keep up the superb work.
https://millionigrushek.ru/
The writing style is captivating. Finally, something that can keep my attention longer than a TikTok video.