Почему imagemin удаляет содержимое svg файла?

149
02 октября 2018, 16:30

Использую такой task для обработки изображений. По сути imagemin должен сжимать svg файлы, но в итоге получается, что он просто удаляет содержимое.

До обработки:

После обработки:

gulp.task('build:img', function() { 
  gulp.src(path.src.img) 
    .pipe(imagemin({ 
      progressive: true, 
      svgoPlugins: [{ 
        removeViewBox: false 
      }], 
      use: [pngquant()], 
      interlaced: true 
    })) 
    .pipe(gulp.dest(path.build.img)) 
    .pipe(browserSync.reload({ 
      stream: true 
    })) 
})

На всякий случай прикрепляю содержимое svg файла:

<svg style="display: none;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 
 
    <symbol id='movie-clapper' viewBox="0 0 277.446 277.446"> 
        <path d="M59.488,117.299c-0.504-4.237-2.007-8.171-4.273-11.556l202.992-67.776L247.552,6.051 
		c-1.549-4.638-6.566-7.141-11.201-5.594L15.54,74.182c-4.635,1.547-7.143,6.563-5.594,11.201l5.225,15.647 
		c-5.216,4.843-8.488,11.752-8.488,19.415c0,9.924,5.486,18.586,13.582,23.127v125.02c0,4.891,3.967,8.853,8.854,8.853h232.793 
		c4.885,0,8.852-3.963,8.852-8.853V117.299H59.488z M188.869,26.724l26.875-8.973l-6.467,26.14l-26.875,8.973L188.869,26.724z 
		 M122.47,48.893l26.877-8.973l-6.467,26.139l-26.875,8.974L122.47,48.893z M33.181,133.946c-7.442,0-13.498-6.056-13.498-13.5 
		c0-7.444,6.056-13.5,13.498-13.5c7.444,0,13.5,6.056,13.5,13.5C46.681,127.89,40.625,133.946,33.181,133.946z M56.074,71.062 
		l26.877-8.973l-6.467,26.14l-26.877,8.974L56.074,71.062z M82.476,147.192H54.142l14.412-22.746h28.334L82.476,147.192z 
		 M138.554,124.446h28.334l-14.412,22.746h-28.334L138.554,124.446z M131.599,234.372v-60l47.783,30L131.599,234.372z 
		 M222.476,147.192h-28.334l14.412-22.746h28.334L222.476,147.192z"/> 
    </symbol> 
 
    <symbol id='laptop' viewBox="0 0 92.821 92.821"> 
		<g> 
			<g> 
				<path d="M77.45,65.06V52.924h-4.452v9.702c0,1.517-1.242,2.756-2.756,2.756H15.106 
					c-1.514,0-2.756-1.238-2.756-2.756V29.554c0-1.521,1.242-2.759,2.756-2.759H46.65v-2.827H11.066c-1.739,0-3.167,1.417-3.167,3.16 
					v18.971V65.06v3.16L0,77.704c0,2.62,2.122,4.746,4.738,4.746h75.868c2.616,0,4.738-2.126,4.738-4.746l-7.899-9.484v-3.16H77.45z 
					 M49.002,80.864H36.354c-0.44,0-0.791-0.351-0.791-0.791s0.351-0.791,0.791-0.791h12.644c0.433,0,0.791,0.351,0.791,0.791 
					C49.782,80.513,49.435,80.864,49.002,80.864z M29.644,77.704l2.412-2.895h21.237l2.412,2.895 
					C55.705,77.704,29.644,77.704,29.644,77.704z"/> 
				<g> 
					<rect x="37.485" y="47.287" width="6.603" height="6.596"/> 
					<rect x="41.622" y="38.219" width="6.599" height="6.603"/> 
					<rect x="48.114" y="46.5" width="6.599" height="6.599"/> 
					<rect x="53.361" y="35.534" width="7.831" height="7.831"/> 
					<rect x="64.437" y="11.531" width="7.831" height="7.831"/> 
					<rect x="50.229" y="25.693" width="7.831" height="7.831"/> 
					<rect x="62.537" y="22.343" width="11.184" height="11.184"/> 
					<rect x="70.89" y="35.824" width="13.528" height="13.532"/> 
					<rect x="76.011" y="10.372" width="16.81" height="16.81"/> 
					<rect x="60.518" y="44.263" width="7.831" height="7.831"/> 
				</g> 
			</g> 
		</g> 
    </symbol> 
 
    <symbol id='next' viewBox="0 0 240.823 240.823"> 
    	<path id="Chevron_Right_1_" d="M183.189,111.816L74.892,3.555c-4.752-4.74-12.451-4.74-17.215,0c-4.752,4.74-4.752,12.439,0,17.179 
		l99.707,99.671l-99.695,99.671c-4.752,4.74-4.752,12.439,0,17.191c4.752,4.74,12.463,4.74,17.215,0l108.297-108.261 
		C187.881,124.315,187.881,116.495,183.189,111.816z"/> 
    </symbol> 
 
    <symbol id='pencil' viewBox="0 0 485.219 485.22"> 
    	<path d="M467.476,146.438l-21.445,21.455L317.35,39.23l21.445-21.457c23.689-23.692,62.104-23.692,85.795,0l42.886,42.897 
		C491.133,84.349,491.133,122.748,467.476,146.438z M167.233,403.748c-5.922,5.922-5.922,15.513,0,21.436 
		c5.925,5.955,15.521,5.955,21.443,0L424.59,189.335l-21.469-21.457L167.233,403.748z M60,296.54c-5.925,5.927-5.925,15.514,0,21.44 
		c5.922,5.923,15.518,5.923,21.443,0L317.35,82.113L295.914,60.67L60,296.54z M338.767,103.54L102.881,339.421 
		c-11.845,11.822-11.815,31.041,0,42.886c11.85,11.846,31.038,11.901,42.914-0.032l235.886-235.837L338.767,103.54z 
		 M145.734,446.572c-7.253-7.262-10.749-16.465-12.05-25.948c-3.083,0.476-6.188,0.919-9.36,0.919 
		c-16.202,0-31.419-6.333-42.881-17.795c-11.462-11.491-17.77-26.687-17.77-42.887c0-2.954,0.443-5.833,0.859-8.703 
		c-9.803-1.335-18.864-5.629-25.972-12.737c-0.682-0.677-0.917-1.596-1.538-2.338L0,485.216l147.748-36.986 
		C147.097,447.637,146.36,447.193,145.734,446.572z"/> 
    </symbol> 
	 
	<symbol id='star' viewBox="0 0 306 306"> 
		<polygon points="153,230.775 247.35,299.625 211.65,187.425 306,121.125 191.25,121.125 153,6.375 114.75,121.125 0,121.125  
			94.35,187.425 58.65,299.625"/> 
	</symbol> 
 
	<symbol id='houses' viewBox="0 0 484.738 484.738"> 
		<path d="M131.012,438.372h85.624v-87.557h51.467v87.557h85.624V46.366H131.012V438.372z M257.993,92.564h51.466v51.467h-51.466 
			V92.564z M257.993,175.279h51.466v51.467h-51.466V175.279z M257.993,257.992h51.466v51.467h-51.466V257.992z M175.279,92.564 
			h51.466v51.467h-51.466V92.564z M175.279,175.279h51.466v51.467h-51.466V175.279z M175.279,257.992h51.466v51.467h-51.466V257.992 
			z"/> 
		<path d="M373.719,81.482V358.66h33.065v79.712h77.954V81.482H373.719z M444.437,321.009H397.58v-46.856h46.856V321.009z 
			 M444.437,245.703H397.58v-46.855h46.856V245.703z M444.437,170.398H397.58v-46.855h46.856V170.398z"/> 
		<path d="M0,438.372h77.954V358.66h33.065V81.482H0V438.372z M40.302,123.543h46.856v46.855H40.302V123.543z M40.302,198.848 
			h46.856v46.855H40.302V198.848z M40.302,274.151h46.856v46.855H40.302V274.151z"/> 
	</symbol> 
 
	<symbol id='search' viewBox="0 0 410.23 410.23"> 
		<path d="M401.625,364.092l-107.1-107.1c19.125-26.775,30.6-59.288,30.6-93.713c0-89.888-72.675-162.562-162.562-162.562 
		S0,73.392,0,163.279s72.675,162.562,162.562,162.562c34.425,0,66.938-11.475,93.713-30.6l107.1,107.1 
		c9.562,9.562,26.775,9.562,38.25,0l0,0C413.1,390.867,413.1,375.566,401.625,364.092z M162.562,287.592 
		c-68.85,0-124.312-55.463-124.312-124.312c0-68.85,55.462-124.312,124.312-124.312c68.85,0,124.312,55.462,124.312,124.312 
		C286.875,232.129,231.412,287.592,162.562,287.592z"/> 
	</symbol> 
 
	<symbol id='visible-field' viewBox="0 0 98.48 98.48"> 
		<path d="M97.204,45.788c-0.865-1.02-21.537-24.945-47.963-24.945c-26.427,0-47.098,23.925-47.965,24.946 
		c-1.701,2-1.701,4.902,0.001,6.904c0.866,1.02,21.537,24.944,47.964,24.944c26.426,0,47.098-23.926,47.964-24.946 
		C98.906,50.691,98.906,47.789,97.204,45.788z M57.313,35.215c1.777-0.97,4.255,0.143,5.534,2.485 
		c1.279,2.343,0.875,5.029-0.902,5.999c-1.776,0.971-4.255-0.143-5.535-2.485C55.132,38.871,55.535,36.185,57.313,35.215z 
		 M49.241,68.969c-18.46,0-33.995-14.177-39.372-19.729c3.631-3.75,11.898-11.429,22.567-16.021 
		c-2.081,3.166-3.301,6.949-3.301,11.021c0,11.104,9.001,20.105,20.105,20.105s20.106-9.001,20.106-20.105 
		c0-4.072-1.219-7.855-3.3-11.021C76.715,37.812,84.981,45.49,88.612,49.24C83.235,54.795,67.7,68.969,49.241,68.969z"/> 
	</symbol> 
 
	<symbol id='comment-black' viewBox="0 0 612 612"> 
		<path d="M83.455,464.734l78.364,91.104c10.015,11.656,26.539,11.545,36.637,0l79.727-91.104h305.917 
		c15.411,0,27.901-12.49,27.901-28.013V75.502c0-15.495-12.212-28.041-27.874-28.041H27.874C12.49,47.461,0,59.952,0,75.502v361.219 
		c0,15.467,12.323,28.013,27.791,28.013H83.455z M111.273,164.91c0-3.394,2.754-6.176,6.12-6.176h349.396 
		c3.422,0,6.12,2.754,6.12,6.176v15.467c0,3.394-2.754,6.176-6.12,6.176H117.393c-3.421,0-6.12-2.754-6.12-6.176V164.91z 
		 M111.273,248.364c0-3.394,2.754-6.176,6.12-6.176h349.396c3.422,0,6.12,2.754,6.12,6.176v15.467c0,3.394-2.754,6.176-6.12,6.176 
		H117.393c-3.421,0-6.12-2.754-6.12-6.176V248.364z M111.273,331.819c0-3.394,2.615-6.176,5.814-6.176h238.735 
		c3.171,0,5.814,2.754,5.814,6.176v15.467c0,3.394-2.615,6.176-5.814,6.176H117.087c-3.171,0-5.814-2.754-5.814-6.176V331.819z"/> 
	</symbol> 
 
	<symbol id='coin' viewBox="0 0 387.469 387.469"> 
		<path d="M104.515,47.127l10.508,4.585c-7.289,4.463-10.578,8.827-9.746,12.983c0.856,4.294,4.781,7.996,11.677,11.007 
		c6.352,2.773,13.836,4.274,22.883,4.59c8.921,0.309,22.683-2.2,40.919-7.464c4.53-1.311,8.081-2.074,10.547-2.264 
		c2.414-0.19,4.36,0.081,6.128,0.855c1.217,0.531,4.927,2.147-4.396,6.219c-6.056,2.643-12.327,3.731-18.635,3.235 
		c-4.991-0.389-10.045,0.531-12.915,2.356l-5.603,3.563c-2.449,1.556-2.945,3.546-1.33,5.296c1.612,1.75,5.131,3.028,9.364,3.408 
		c13.836,1.242,27.493-0.351,40.614-4.712l14.184,6.193c5.041,2.2,13.207,2.2,18.246,0.005c5.037-2.201,5.037-5.767,0-7.966 
		l-14.678-6.408c6.447-4.096,9.838-8.236,10.076-12.331c0.284-4.791-3.586-8.973-11.499-12.428 
		c-5.648-2.466-12.09-3.992-19.136-4.534c-7.047-0.547-13.727-0.242-19.842,0.905c-6.033,1.134-15.215,3.422-27.235,6.786 
		c-5.231,1.449-8.779,2.188-10.557,2.199c-1.699,0.009-3.222-0.26-4.402-0.777c-4.188-1.824-0.669-4.131,3.02-5.741 
		c4.58-1.999,9.467-2.943,14.522-2.81c5.068,0.134,9.848-1.049,12.199-3.011l3.25-2.711c2.056-1.714,1.946-3.77-0.287-5.444 
		c-2.231-1.671-6.276-2.727-10.708-2.793c-9.619-0.138-18.896,1.148-28.23,3.913l-10.694-4.667c-5.04-2.2-13.207-2.2-18.246,0 
		C99.479,41.362,99.479,44.928,104.515,47.127z"/> 
		<path d="M326.447,104.012c0.854-3.551,1.291-7.168,1.291-10.834V81.59c0-23.154-17.287-44.325-48.677-59.612 
		C249.96,7.805,211.49,0,170.738,0C129.986,0,91.517,7.805,62.415,21.978C31.025,37.265,13.738,58.436,13.738,81.59v11.588 
		c0,22.833,16.82,43.733,47.387,58.968c-0.848,3.534-1.395,7.938-1.395,10.782v2.114c-29.688,15.173-45.992,35.786-45.992,58.27 
		V234.9c0,15.613,7.871,30.321,22.616,42.936c-1.995,5.332-3.035,10.833-3.035,16.455v11.588c0,23.154,17.287,44.325,48.677,59.612 
		c29.102,14.173,67.571,21.978,108.323,21.978c40.752,0,79.222-7.805,108.323-21.978c31.39-15.287,48.677-36.458,48.677-59.612 
		v-11.588c0-15.61-7.864-30.316-22.603-42.929c1.993-5.333,3.021-10.839,3.021-16.462v-2.114 
		c29.688-15.173,45.992-35.786,45.992-58.271v-11.588C373.73,140.121,356.948,119.243,326.447,104.012z M35.679,71.784 
		c4.547-11.561,16.932-22.786,35.493-31.825C97.6,27.088,132.96,20,170.738,20c37.778,0,73.139,7.088,99.566,19.959 
		c18.562,9.039,30.946,20.265,35.493,31.825c-16.064,27.942-71.876,48.316-135.06,48.316S51.742,99.727,35.679,71.784z 
		 M35.679,213.507c3.697-9.399,12.601-18.569,25.769-26.53c5.073,18.229,21.303,34.656,46.96,47.151 
		c29.102,14.173,67.571,21.978,108.323,21.978c3.983,0,7.938-0.097,11.871-0.244c-17.791,3.826-37.438,5.962-57.863,5.962 
		C107.555,261.823,51.742,241.449,35.679,213.507z M325.379,284.485c-16.064,27.942-71.876,48.316-135.06,48.316 
		c-54.888,0-104.183-15.383-126.718-37.738c28.959,13.815,66.928,21.427,107.137,21.427c40.752,0,79.222-7.805,108.323-21.978 
		c15.078-7.344,26.892-16.047,35.109-25.674C319.473,273.861,323.275,279.135,325.379,284.485z M216.73,201.439 
		c-55.166,0-104.709-15.532-127.088-38.071c24.167,7.414,52.041,11.4,81.096,11.4c40.752,0,79.222-7.805,108.323-21.977 
		c17.622-8.582,30.798-19.019,38.967-30.619c17.591,8.885,29.359,19.757,33.762,30.951 
		C335.727,181.064,279.914,201.439,216.73,201.439z"/> 
	</symbol> 
 
	<symbol id='email' viewBox="0 0 230.17 230.17"> 
		<path d="M230,49.585c0-0.263,0.181-0.519,0.169-0.779l-70.24,67.68l70.156,65.518c0.041-0.468-0.085-0.94-0.085-1.418V49.585z"/> 
		<path d="M149.207,126.901l-28.674,27.588c-1.451,1.396-3.325,2.096-5.2,2.096c-1.836,0-3.672-0.67-5.113-2.013l-28.596-26.647 
			L11.01,195.989c1.717,0.617,3.56,1.096,5.49,1.096h197.667c2.866,0,5.554-0.873,7.891-2.175L149.207,126.901z"/> 
		<path d="M115.251,138.757L222.447,35.496c-2.427-1.443-5.252-2.411-8.28-2.411H16.5c-3.943,0-7.556,1.531-10.37,3.866 
			L115.251,138.757z"/> 
		<path d="M0,52.1v128.484c0,1.475,0.339,2.897,0.707,4.256l69.738-67.156L0,52.1z"/> 
	</symbol> 
 
	<symbol id='location' viewBox="0 0 430.114 430.114"> 
		<path id="Facebook_Places" d="M356.208,107.051c-1.531-5.738-4.64-11.852-6.94-17.205C321.746,23.704,261.611,0,213.055,0 
		C148.054,0,76.463,43.586,66.905,133.427v18.355c0,0.766,0.264,7.647,0.639,11.089c5.358,42.816,39.143,88.32,64.375,131.136 
		c27.146,45.873,55.314,90.999,83.221,136.106c17.208-29.436,34.354-59.259,51.17-87.933c4.583-8.415,9.903-16.825,14.491-24.857 
		c3.058-5.348,8.9-10.696,11.569-15.672c27.145-49.699,70.838-99.782,70.838-149.104v-20.262 
		C363.209,126.938,356.581,108.204,356.208,107.051z M214.245,199.193c-19.107,0-40.021-9.554-50.344-35.939 
		c-1.538-4.2-1.414-12.617-1.414-13.388v-11.852c0-33.636,28.56-48.932,53.406-48.932c30.588,0,54.245,24.472,54.245,55.06 
		C270.138,174.729,244.833,199.193,214.245,199.193z"/> 
	</symbol> 
 
	<symbol id='newspaper' viewBox="0 0 32 32"> 
		<path d="M28,7V3H0v22c0,0,0,4,4,4h25c0,0,3-0.062,3-4V7H28z M4,27c-2,0-2-2-2-2V5h24v20 
			c0,0.921,0.284,1.559,0.676,2H4z"/> 
		<rect x="4" y="9"  width="20" height="2"/> 
		<rect x="15" y="21"  width="7" height="2"/> 
		<rect x="15" y="17" width="9" height="2"/> 
		<rect x="15" y="13" width="9" height="2"/> 
		<rect x="4" y="13" width="9" height="10"/> 
	</symbol> 
 
	<symbol id='forbidden' viewBox="0 0 174.239 174.239"> 
		<path d="M146.537,1.047c-1.396-1.396-3.681-1.396-5.077,0L89.658,52.849c-1.396,1.396-3.681,1.396-5.077,0L32.78,1.047 
		c-1.396-1.396-3.681-1.396-5.077,0L1.047,27.702c-1.396,1.396-1.396,3.681,0,5.077l51.802,51.802c1.396,1.396,1.396,3.681,0,5.077 
		L1.047,141.46c-1.396,1.396-1.396,3.681,0,5.077l26.655,26.655c1.396,1.396,3.681,1.396,5.077,0l51.802-51.802 
		c1.396-1.396,3.681-1.396,5.077,0l51.801,51.801c1.396,1.396,3.681,1.396,5.077,0l26.655-26.655c1.396-1.396,1.396-3.681,0-5.077 
		l-51.801-51.801c-1.396-1.396-1.396-3.681,0-5.077l51.801-51.801c1.396-1.396,1.396-3.681,0-5.077L146.537,1.047z"/> 
	</symbol> 
 
	<symbol id='home' viewBox="0 0 460.298 460.297"> 
		<path d="M230.149,120.939L65.986,256.274c0,0.191-0.048,0.472-0.144,0.855c-0.094,0.38-0.144,0.656-0.144,0.852v137.041 
			c0,4.948,1.809,9.236,5.426,12.847c3.616,3.613,7.898,5.431,12.847,5.431h109.63V303.664h73.097v109.64h109.629 
			c4.948,0,9.236-1.814,12.847-5.435c3.617-3.607,5.432-7.898,5.432-12.847V257.981c0-0.76-0.104-1.334-0.288-1.707L230.149,120.939 
			z"/> 
		<path d="M457.122,225.438L394.6,173.476V56.989c0-2.663-0.856-4.853-2.574-6.567c-1.704-1.712-3.894-2.568-6.563-2.568h-54.816 
			c-2.666,0-4.855,0.856-6.57,2.568c-1.711,1.714-2.566,3.905-2.566,6.567v55.673l-69.662-58.245 
			c-6.084-4.949-13.318-7.423-21.694-7.423c-8.375,0-15.608,2.474-21.698,7.423L3.172,225.438c-1.903,1.52-2.946,3.566-3.14,6.136 
			c-0.193,2.568,0.472,4.811,1.997,6.713l17.701,21.128c1.525,1.712,3.521,2.759,5.996,3.142c2.285,0.192,4.57-0.476,6.855-1.998 
			L230.149,95.817l197.57,164.741c1.526,1.328,3.521,1.991,5.996,1.991h0.858c2.471-0.376,4.463-1.43,5.996-3.138l17.703-21.125 
			c1.522-1.906,2.189-4.145,1.991-6.716C460.068,229.007,459.021,226.961,457.122,225.438z"/> 
	</symbol> 
 
	<symbol id='arrow-left' viewBox="0 0 306 306"> 
		<polygon points="247.35,35.7 211.65,0 58.65,153 211.65,306 247.35,270.3 130.05,153"/> 
	</symbol> 
 
 
</svg>

Answer 1

Нужно было у SVG спрайта убрать display: none;

READ ALSO
Как получить label выбраного option в datalist?

Как получить label выбраного option в datalist?

Пытаюсь получить значение ( label ) выбранного вариант с ползука ( range )

168
Как избавиться от лишней таблицы в бд

Как избавиться от лишней таблицы в бд

Суть: данная таблица хорошо подходит для описания моих сущностный, проблемы возникают только из-за 2 полейПоле ganre_id может быть у одной сущности,...

182
Sql запрос возвращает дубликаты

Sql запрос возвращает дубликаты

Всем приветВот скрин моей схемы

202
Помогите доработать код jquery

Помогите доработать код jquery

Есть вот такой вот проблема https://jsfiddlenet/aq9Laaew/118529/

176