Skip to content

Commit

Permalink
[shopsys] Some fixes in webpack for css and image (#1781)
Browse files Browse the repository at this point in the history
  • Loading branch information
pesektomas authored Apr 27, 2020
2 parents e3adc0c + f15e6b0 commit 2b195ae
Show file tree
Hide file tree
Showing 115 changed files with 35 additions and 512 deletions.
4 changes: 2 additions & 2 deletions assets/js/commands/svg/generateWebFont.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const WebfontsGenerator = require('webfonts-generator');
const optimizeSvg = require('./optimizeSvg');

function generateWebFont (type, svgSourceFolder) {
function generateWebFont (type, svgSourceFolder, svgDestinationFolder = null) {

optimizeSvg(svgSourceFolder).then(svgFilesPath => {
optimizeSvg(svgSourceFolder, svgDestinationFolder).then(svgFilesPath => {
WebfontsGenerator({
files: svgFilesPath,
dest: 'assets/public/' + type + '/fonts',
Expand Down
47 changes: 28 additions & 19 deletions assets/js/commands/svg/optimizeSvg.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
const glob = require('glob');
const fs = require('fs');
const glob = require('glob');
const path = require('path');
const SVGO = require('svgo');

const svgo = new SVGO();
const writeSvg = (svgOptimizedFile, optimizedSvg) => {
try {
fs.writeFileSync(svgOptimizedFile, optimizedSvg);
} catch (err) {
console.log('ERROR: SVG icon ' + svgOptimizedFile + ' optimize failed');
}
};

function optimizeSvg (svgSourceFolder, svgDestinationFolder = null) {
const svgo = new SVGO();

if (svgDestinationFolder === null) {
svgDestinationFolder = svgSourceFolder;
}

if (!fs.existsSync(svgDestinationFolder)) {
fs.mkdirSync(svgDestinationFolder, { recursive: true });
}

function optimizeSvg (svgSourceFolder) {
return new Promise((resolve, reject) => {
return glob(svgSourceFolder, null, (err, svgFiles) => {
glob(svgSourceFolder + '**/*.svg', null, (err, svgFiles) => {
if (err) {
reject(err);
}

svgFiles.forEach(svgFile => {
fs.readFile(svgFile, 'utf8', function (err, data) {
if (err) {
throw err;
}
svgo.optimize(data, { path: svgFile }).then(function (result) {
fs.writeFile(svgFile, result.data, function (errorOptimize) {
if (errorOptimize) {
console.log('ERROR: SVG icon ' + svgFile + ' optimize failed');
throw errorOptimize;
}
});
});
});
const svgOptimizedFiles = svgFiles.map(svgFile => {
const svgOptimizedFile = svgDestinationFolder + path.basename(svgFile);
const optimizedSvg = fs.readFileSync(svgFile, 'utf8');
svgo.optimize(optimizedSvg, { path: svgFile }).then(result => writeSvg(svgOptimizedFile, result.data));

return svgOptimizedFile;
});

resolve(svgFiles);
resolve(svgOptimizedFiles);
});
});
}
Expand Down
Binary file removed assets/public/admin/fonts/Roboto400.ttf
Binary file not shown.
Binary file removed assets/public/admin/fonts/Roboto400.woff2
Binary file not shown.
Binary file removed assets/public/admin/fonts/Roboto500.ttf
Binary file not shown.
Binary file removed assets/public/admin/fonts/Roboto500.woff2
Binary file not shown.
Binary file removed assets/public/admin/images/bg/disabled.png
Binary file not shown.
Binary file removed assets/public/admin/images/custom_checkbox.png
Binary file not shown.
Binary file removed assets/public/admin/images/custom_radio.png
Binary file not shown.
Binary file removed assets/public/admin/images/flags/cs.png
Binary file not shown.
Binary file removed assets/public/admin/images/flags/de.png
Binary file not shown.
Binary file removed assets/public/admin/images/flags/en.png
Binary file not shown.
Binary file removed assets/public/admin/images/flags/hu.png
Binary file not shown.
Binary file removed assets/public/admin/images/flags/pl.png
Binary file not shown.
Binary file removed assets/public/admin/images/flags/sk.png
Binary file not shown.
Binary file removed assets/public/admin/images/icons/level.png
Binary file not shown.
Binary file removed assets/public/admin/images/icons/star.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
151 changes: 0 additions & 151 deletions assets/public/admin/images/logo.svg

This file was deleted.

Binary file removed assets/public/admin/images/preloader.gif
Binary file not shown.
1 change: 0 additions & 1 deletion assets/public/admin/images/sprites/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-back.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-down.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-left.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-simple.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-strong.svg
Diff not rendered.
1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-thin.svg
Diff not rendered.
1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow-up.svg
Diff not rendered.
1 change: 0 additions & 1 deletion assets/public/admin/svg/arrow.svg
Diff not rendered.
1 change: 0 additions & 1 deletion assets/public/admin/svg/calendar-3.svg
Diff not rendered.
1 change: 0 additions & 1 deletion assets/public/admin/svg/cart.svg
Diff not rendered.
Loading

0 comments on commit 2b195ae

Please sign in to comment.