@24i/smartapps-bigscreen-rnv-build-engine 0.10.3-alpha.1564 → 0.10.3-alpha.1566

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ describe('generatePngSpriteMap', () => {
30
30
  },
31
31
  buildConfig: {
32
32
  common: {
33
- svgIconsMaskList: [],
33
+ pngIconPrefix: 'png-',
34
34
  },
35
35
  },
36
36
  };
@@ -50,5 +50,13 @@ describe('generatePngSpriteMap', () => {
50
50
  await (0, generatePngSpriteMap_1.generatePngSpriteMap)(rnvC);
51
51
  expect(fs_1.default.existsSync(path_1.default.resolve(runtimeDir, 'png_icons.css'))).toBeTruthy();
52
52
  expect(fs_1.default.existsSync(path_1.default.resolve(platformAssetsDir, 'png_icons.json'))).toBeTruthy();
53
+ const outputJsonPath = path_1.default.resolve(platformAssetsDir, 'png_icons.json');
54
+ expect(fs_1.default.existsSync(outputJsonPath)).toBe(true);
55
+ const outputJsonContent = JSON.parse(fs_1.default.readFileSync(outputJsonPath).toString());
56
+ expect(Object.keys(outputJsonContent)).toStrictEqual([
57
+ 'png-icon1',
58
+ 'png-icon2',
59
+ 'png-icon3',
60
+ ]);
53
61
  });
54
62
  });
@@ -35,6 +35,7 @@ describe('generateSvgSpriteMap', () => {
35
35
  buildConfig: {
36
36
  common: {
37
37
  svgIconsMaskList: [],
38
+ svgIconPrefix: 'svg-',
38
39
  },
39
40
  },
40
41
  };
@@ -79,29 +80,29 @@ describe('generateSvgSpriteMap', () => {
79
80
  expect(fs_1.default.existsSync(outputCssFilePath)).toBe(true);
80
81
  const outputCssContentRows = fs_1.default.readFileSync(outputCssFilePath).toString().split('\n');
81
82
  expect(outputCssContentRows).toHaveLength(15);
82
- expect(outputCssContentRows[0]).toBe('.icon-icon1 {');
83
+ expect(outputCssContentRows[0]).toBe('.icon-svg-icon1 {');
83
84
  expect(outputCssContentRows[1].startsWith(' background-image: url(')).toBe(true);
84
85
  expect(outputCssContentRows[2]).toBe('}');
85
86
  expect(outputCssContentRows[3]).toBe('');
86
- expect(outputCssContentRows[4]).toBe('.icon-mask-icon1 {');
87
+ expect(outputCssContentRows[4]).toBe('.icon-mask-svg-icon1 {');
87
88
  expect(outputCssContentRows[5].startsWith(' -webkit-mask-image: url(')).toBe(true);
88
89
  expect(outputCssContentRows[6]).toBe('}');
89
90
  expect(outputCssContentRows[7]).toBe('');
90
- expect(outputCssContentRows[8]).toBe('.icon-icon2 {');
91
+ expect(outputCssContentRows[8]).toBe('.icon-svg-icon2 {');
91
92
  expect(outputCssContentRows[9].startsWith(' background-image: url(')).toBe(true);
92
93
  expect(outputCssContentRows[10]).toBe('}');
93
94
  expect(outputCssContentRows[11]).toBe('');
94
- expect(outputCssContentRows[12]).toBe('.icon-icon3 {');
95
+ expect(outputCssContentRows[12]).toBe('.icon-svg-icon3 {');
95
96
  expect(outputCssContentRows[13].startsWith(' background-image: url(')).toBe(true);
96
97
  expect(outputCssContentRows[14]).toBe('}');
97
98
  const outputJsonPath = path_1.default.resolve(platformAssetsDir, 'svg_icons.json');
98
99
  expect(fs_1.default.existsSync(outputJsonPath)).toBe(true);
99
100
  const outputJsonContent = JSON.parse(fs_1.default.readFileSync(outputJsonPath).toString());
100
101
  expect(outputJsonContent).toStrictEqual({
101
- icon1: '',
102
- icon2: '',
103
- icon3: '',
104
- 'mask-icon1': '',
102
+ 'svg-icon1': '',
103
+ 'svg-icon2': '',
104
+ 'svg-icon3': '',
105
+ 'mask-svg-icon1': '',
105
106
  });
106
107
  });
107
108
  });
@@ -7,7 +7,7 @@ exports.generatePngSpriteMap = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const webpack_1 = __importDefault(require("webpack"));
9
9
  const webpack_spritesmith_1 = __importDefault(require("webpack-spritesmith"));
10
- const makeWebpackSpritesmithConfig = (projectDir, appBuildDir) => ({
10
+ const makeWebpackSpritesmithConfig = (projectDir, appBuildDir, iconPrefix) => ({
11
11
  entry: {
12
12
  polyfill: path_1.default.resolve(projectDir, 'polyfill/index.ts'),
13
13
  bundle: path_1.default.resolve(projectDir, 'index.js'),
@@ -28,9 +28,8 @@ const makeWebpackSpritesmithConfig = (projectDir, appBuildDir) => ({
28
28
  apiOptions: {
29
29
  cssImageRef: 'sprite.png',
30
30
  generateSpriteName: (fullPathToSourceFile) => {
31
- console.log('image:', fullPathToSourceFile);
32
31
  const { name } = path_1.default.parse(fullPathToSourceFile);
33
- return `png-${name}`;
32
+ return `${iconPrefix}${name}`;
34
33
  },
35
34
  },
36
35
  }),
@@ -51,7 +50,8 @@ const runSpritesmith = (config) => (new Promise((resolve) => {
51
50
  const generatePngSpriteMap = async (c) => {
52
51
  const projectDir = c.paths.project.dir;
53
52
  const rnvBuildDirPath = `${c.paths.project.builds.dir}/${c.runtime.appId}_${c.platform}`;
54
- const config = makeWebpackSpritesmithConfig(projectDir, rnvBuildDirPath);
53
+ const iconPrefix = c.buildConfig?.common.pngIconPrefix || '';
54
+ const config = makeWebpackSpritesmithConfig(projectDir, rnvBuildDirPath, iconPrefix);
55
55
  await runSpritesmith(config);
56
56
  };
57
57
  exports.generatePngSpriteMap = generatePngSpriteMap;
@@ -54,6 +54,7 @@ const generateSvgSpriteMap = (c) => {
54
54
  cssOutput: '../../platformAssets/runtime/svg_icons.css',
55
55
  jsonOutput: '../../platformAssets/svg_icons.json',
56
56
  maskList: c.buildConfig?.common.svgIconsMaskList || [],
57
+ iconPrefix: c.buildConfig?.common.svgIconPrefix || '',
57
58
  };
58
59
  const projectPaths = c.paths.project;
59
60
  const iconsPath = path_1.default.join(projectPaths.dir, config.iconsFolder);
@@ -85,7 +86,7 @@ const generateSvgSpriteMap = (c) => {
85
86
  .filter((name) => name.endsWith('.svg'))
86
87
  .map((fileName) => {
87
88
  const maskListIncludesFileName = config.maskList.includes(fileName);
88
- const spriteName = fileName
89
+ const spriteName = `${config.iconPrefix}${fileName}`
89
90
  .replace('.svg', '')
90
91
  .replace(' ', '-')
91
92
  .toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/smartapps-bigscreen-rnv-build-engine",
3
- "version": "0.10.3-alpha.1564+4e08fa06",
3
+ "version": "0.10.3-alpha.1566+9415bfeb",
4
4
  "description": "Package with build engine for SmartApps BIGscreen projects... ",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -61,5 +61,5 @@
61
61
  "keywords": [],
62
62
  "author": "24i",
63
63
  "license": "ISC",
64
- "gitHead": "4e08fa06d7ee0d08fceffb134783a7af0ad3dbc4"
64
+ "gitHead": "9415bfebfa0fb2ecd1c930d399acae2a862162d7"
65
65
  }