Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add robots.txt and sitemap.xml using SitemapWebpackPlugin #47

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"purgecss-webpack-plugin": "^7.0.2",
"sass": "^1.81.0",
"sass-loader": "^16.0.3",
"sitemap-webpack-plugin": "^1.1.1",
"template-ejs-loader": "^0.9.4",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.96.1",
Expand Down
4 changes: 4 additions & 0 deletions src/asset/raw/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Disallow:

Sitemap: https://bvarga.dev/sitemap.xml
13 changes: 13 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const { PurgeCSSPlugin } = require('purgecss-webpack-plugin');
const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin');
const HtmlInlineScriptWebpackPlugin = require('html-inline-script-webpack-plugin');
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
const SitemapWebpackPlugin = require('sitemap-webpack-plugin').default;

const baseUrl = 'https://bvarga.dev';
const glob = require('glob');
const path = require('path');
const context = path.join(__dirname, 'src');
Expand Down Expand Up @@ -151,6 +153,17 @@ module.exports = {
new HtmlInlineScriptWebpackPlugin({
scriptMatchPattern: [/.*\.js?$/], // Match hashed JS files
}),
new SitemapWebpackPlugin({
base: baseUrl,
paths: [
{
path: '/',
}
],
options: {
lastmod: true,
}
}),
],
optimization: {
minimize: true,
Expand Down