meta data for this page
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ixc2024:tech:tools:webpack [2024/05/22 12:05] – created alesta | ixc2024:tech:tools:webpack [2024/08/26 05:10] (current) – salsabeel-tn | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | . | + | \\ |
+ | link: https:// | ||
+ | \\ | ||
+ | Green Aspect: | ||
+ | |||
+ | Caching: Proper caching strategies ensure that users don’t have to re-download unchanged assets. This reduces the load on servers and the amount of data transferred, | ||
+ | How to Implement: | ||
+ | |||
+ | Use content hashing to create unique filenames for your assets, which helps in long-term caching. | ||
+ | Example: | ||
+ | '' | ||
+ | module.exports = { | ||
+ | output: { | ||
+ | filename: ' | ||
+ | path: path.resolve(__dirname, | ||
+ | }, | ||
+ | }; | ||
+ | '' | ||
+ | \\ | ||
+ | |||
+ | Using HtmlWebpackPlugin to clean the code structure: | ||
+ | |||
+ | |||
+ | const HtmlWebpackPlugin = require(' | ||
+ | |||
+ | module.exports = { | ||
+ | plugins: [ | ||
+ | new HtmlWebpackPlugin({ | ||
+ | template: ' | ||
+ | minify: { | ||
+ | removeComments: | ||
+ | collapseWhitespace: | ||
+ | }, | ||
+ | }), | ||
+ | ], | ||
+ | // other configurations... | ||
+ | }; | ||
+ | |||
+ | \\ | ||
+ | Green Development Practices | ||
+ | |||
+ | Development Server: Use Webpack’s development server efficiently to avoid unnecessary resource usage. | ||
+ | How to Implement: | ||
+ | |||
+ | Configure the development server to use minimal resources. | ||
+ | Example: | ||
+ | |||
+ | |||
+ | module.exports = { | ||
+ | devServer: { | ||
+ | contentBase: | ||
+ | compress: true, | ||
+ | port: 9000 | ||
+ | }, | ||
+ | // other configurations... | ||
+ | }; |