Skip to content

Commit

Permalink
fix(IconSearchMap): Restore height/width and fix underlying viewbox i…
Browse files Browse the repository at this point in the history
…ssue

the height and width on the raw SVG file were both set to 24 (matching the viewbox definition). Surprisngly, the image was being cut off. I found that removing the height/width properties resolved the issue. Looking further into it, the viewport was being removed by svgo - see [this](svg/svgo#1128) extensively discussed issue. Since we are re-scaling the svg with CSS to 20x20, we do need to preserve the image viewbox. Applying the solution from [this](svg/svgo#1128 (comment)) comment
  • Loading branch information
KaylaBrady committed Jan 23, 2023
1 parent c4144d8 commit 212519f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assets/static/images/icon-search-map.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions assets/svgo.yml

This file was deleted.

35 changes: 28 additions & 7 deletions assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ const path = require("path")
const glob = require("glob")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const TerserPlugin = require("terser-webpack-plugin")
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin")
const CopyWebpackPlugin = require("copy-webpack-plugin")

module.exports = (env, options) => {
const plugins = [
new MiniCssExtractPlugin({ filename: "../css/app.css" }),
new CopyWebpackPlugin({ patterns: [{ from: "static/", to: "../" }] })
new CopyWebpackPlugin({ patterns: [{ from: "static/", to: "../" }] }),
]

const useMinimization = options.mode === "production";
const useMinimization = options.mode === "production"

return({
return {
optimization: {
minimize: useMinimization,
minimizer: [
new TerserPlugin({ parallel: true }),
new CssMinimizerPlugin(),
],
},
devtool: 'source-map',
devtool: "source-map",
entry: {
"./js/app.tsx": ["./src/app.tsx"].concat(glob.sync("./vendor/**/*.js")),
},
Expand Down Expand Up @@ -59,7 +59,28 @@ module.exports = (env, options) => {
{
loader: "svgo-loader",
options: {
externalConfig: "svgo.yml",
plugins: [
{
name: "preset-default",
params: {
overrides: {
// viewBox is required to resize SVGs with CSS.
// @see https://github.com/svg/svgo/issues/1128
removeViewBox: false,
},
},
},
{
name: "removeTitle",
active: true,
},
{
name: "removeAttrs",
params: {
attrs: ["id"],
},
},
],
},
},
],
Expand All @@ -75,5 +96,5 @@ module.exports = (env, options) => {
modules: ["deps", "node_modules"],
},
plugins: plugins,
})
}
}

0 comments on commit 212519f

Please sign in to comment.