[start page] refactoring for svg sprites

This commit is contained in:
maxkadushkin
2023-10-10 18:48:59 +03:00
parent 8a6a4a9c09
commit fddb1ba162
5 changed files with 99 additions and 93 deletions

2
.gitignore vendored
View File

@ -34,7 +34,7 @@ win-linux/package/linux/tar
/common/loginpage/res/img/common.svg
common/loginpage/build/plugins/*
common/loginpage/build/node_modules/*
common/**/build/node_modules/*
common/loginpage/build/sprites/node_modules
common/loginpage/deploy/*
common/loginpage/src/dlglogin.min.js

View File

@ -163,14 +163,14 @@ module.exports = function(grunt) {
}
});
grunt.registerTask('prebuild-sprites', function() {
require('./sprites/Gruntfile.js')(grunt,'../');
grunt.registerTask('prebuild-svg-sprites', function() {
require('./sprites/sprites')(grunt, '../');
grunt.task.run('svg_sprite');
});
doRegisterInitializeAppTask('startpage', 'Desktop start page', 'startpage.json');
grunt.registerTask('deploy-desktop-startpage', ['prebuild-sprites','desktop-app-extra', 'copy', 'less', 'terser:dialogconnect',
grunt.registerTask('deploy-desktop-startpage', ['prebuild-svg-sprites','desktop-app-extra', 'copy', 'less', 'terser:dialogconnect',
'concat', 'clean', 'inline', 'terser:core', 'terser:langs', 'htmlmin', 'compile-html']);
grunt.registerTask('default', ['init-build-startpage','deploy-desktop-startpage']);
};

View File

@ -11,6 +11,7 @@
"grunt-contrib-htmlmin": "^3.1.0",
"grunt-contrib-less": "^3.0.0",
"grunt-inline": "file:plugins/grunt-inline",
"iconsprite": "file:sprites",
"grunt-terser": "^2.0.0",
"grunt-text-replace": "0.4.0",
"lodash": "^4.17.20",

View File

@ -1,93 +1,6 @@
module.exports = function (grunt, rootpathprefix) {
const _path = rootpathprefix || '../../';
grunt.initConfig({
svg_sprite:{
options: {
svg: {
rootAttributes: {
//xmlns:'http://www.w3.org/2000/svg',
},
},
shape: {
id: {
separator: ""
},
transform: [{
svgo: {
plugins: [
'removeXMLNS',
{
name: "removeAttrs",
params: {
attrs: "(fill|stroke)"
}
},
]
},
}]
},
mode: {
symbol: {
},
},
},
allconnect: {
src: [`${_path}res/img/connect*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `allconnect.svg`,
},
},
}
},
allwelcome: {
src: [`${_path}res/img/welcome*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `allwelcome.svg`,
},
},
}
},
formats: {
src: [`${_path}res/img/formats-svg/*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `format.svg`,
},
},
}
},
common: {
src: [`${_path}res/img/common-svg/*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `common.svg`,
},
},
}
},
}
});
module.exports = function (grunt) {
require('./sprites')(grunt);
// Load in `grunt-spritesmith`
grunt.loadNpmTasks('grunt-svg-sprite');
grunt.registerTask('generate-sprite', ['svg_sprite']);
grunt.registerTask('default', ['generate-sprite']);
};

View File

@ -0,0 +1,92 @@

module.exports = (grunt, rootpathprefix) => {
const _path = rootpathprefix || '../../';
grunt.initConfig({
svg_sprite:{
options: {
svg: {
rootAttributes: {
//xmlns:'http://www.w3.org/2000/svg',
},
},
shape: {
id: {
separator: ""
},
transform: [{
svgo: {
plugins: [
'removeXMLNS',
{
name: "removeAttrs",
params: {
attrs: "(fill|stroke)"
}
},
]
},
}]
},
mode: {
symbol: {
},
},
},
allconnect: {
src: [`${_path}res/img/connect*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `allconnect.svg`,
},
},
}
},
allwelcome: {
src: [`${_path}res/img/welcome*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `allwelcome.svg`,
},
},
}
},
formats: {
src: [`${_path}res/img/formats-svg/*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `formats.svg`,
},
},
}
},
common: {
src: [`${_path}res/img/common-svg/*.svg`],
dest: `${_path}res/img/`,
options: {
mode: {
symbol: {
inline: true,
dest: './',
sprite: `common.svg`,
},
},
}
},
}
});
grunt.loadNpmTasks('grunt-svg-sprite');
grunt.registerTask('generate-sprite', ['svg_sprite']);
}