Hi all,
Apparently yarn build:production
corrupts my checkbox SVG at TailwindCSS Custom Forms.
Here is my marked checkbox on local VS remote. The remote tickbox is not displayed.
yarn build
produces valid SVG:
resulting SVG
url(“data:image/svg+xml,%3csvg viewBox=‘0 0 16 16’ fill=‘white’ xmlns=‘SVG namespace’%3e%3cpath d=‘M5.707 7.293a1 1 0 0 0-1.414 1.414l2 2a1 1 0 0 0 1.414 0l4-4a1 1 0 0 0-1.414-1.414L7 8.586 5.707 7.293z’/%3e%3c/svg%3e”)
yarn build:production
produces corrupted SVG:
resulting checkbox SVG is messed up
url(“data:image/svg+xml;charset=utf-8,%3Csvg viewBox=‘0 0 16 16’ fill=’%23fff’ xmlns=‘SVG namespace’%3E%3Cpath d=‘M5.707 7.293a1 1 0 0-1.414 1.414 NaNl-.828 NaNa1 1 0 1.414 0 NaN NaNlNaN NaNa1 1 0 0-1.414 NaN NaNlNaN NaN NaN NaNz’/%3E%3C/svg%3E”)
I have tried tweaking my svgo plugins at webpack.config.optimize.js
and then running yarn build:production
. However, build results do not change - I can see that my svg is corrupted after the build.
I am sure I am editing the correct file because my build breaks if webpack.config.optimize.js
has incorrect syntax.
Here is my tweaked webpack.config.optimize.js
with everything set to false:
webpack.config.optimize.js
'use strict'; // eslint-disable-line
const { default: ImageminPlugin } = require('imagemin-webpack-plugin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const config = require('./config');
module.exports = {
plugins: [
new ImageminPlugin({
optipng: { optimizationLevel: 2 },
gifsicle: { optimizationLevel: 3 },
pngquant: { quality: '65-90', speed: 4 },
svgo: {
plugins: [
{ removeUnknownsAndDefaults: false },
{ cleanupIDs: false },
{ removeViewBox: false },
//trying to fix my corrupted SVG:
{ removeXMLNS: false },
{ prefixIds: false },
{ cleanupListOfValues: false },
{ removeRasterImages: false },
{ sortAttrs: false },
{ removeDimensions: false },
{ removeAttrs: false },
{ removeAttributesBySelector: false },
{ removeElementsByAttr: false },
{ addClassesToSVGElement: false },
{ addAttributesToSVGElement: false },
{ removeOffCanvasPaths: false },
{ removeStyleElement: false },
{ removeScriptElement: false },
{ reusePaths: false },
{ cleanupAttrs: false },
{ inlineStyles: false },
{ removeDoctype: false },
{ removeXMLProcInst: false },
{ removeComments: false },
{ removeMetadata: false },
{ removeTitle: false },
{ removeDesc: false },
{ removeUselessDefs: false },
{ removeEditorsNSData: false },
{ removeEmptyAttrs: false },
{ removeHiddenElems: false },
{ removeEmptyText: false },
{ removeEmptyContainers: false },
{ removeViewBox: false },
{ cleanupEnableBackground: false },
{ minifyStyles: false },
{ convertStyleToAttrs: false },
{ convertColors: false },
{ convertPathData: false },
{ convertTransform: false },
{ removeUnknownsAndDefaults: false },
{ removeNonInheritableGroupAttrs: false },
{ removeUselessStrokeAndFill: false },
{ removeUnusedNS: false },
{ cleanupIDs: false },
{ cleanupNumericValues: false },
{ moveElemsAttrsToGroup: false },
{ moveGroupAttrsToElems: false },
{ collapseGroups: false },
{ mergePaths: false },
{ convertShapeToPath: false },
{ convertEllipseToCircle: false },
{ sortDefsChildren: false },
],
},
plugins: [imageminMozjpeg({ quality: 75 })],
disable: (config.enabled.watcher),
}),
new UglifyJsPlugin({
uglifyOptions: {
ecma: 5,
compress: {
warnings: true,
drop_console: true,
},
},
}),
],
};
Can someone explain what is going on? I am slowly losing my mind over this issue. Thanks.