@liquidlight/vite-framework 1.0.0 → 1.1.0
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.
- package/dist/cjs/baseConfig.js +15 -30
- package/dist/cjs/baseConfig.js.map +1 -1
- package/dist/cjs/sprites.d.ts +4 -0
- package/dist/cjs/sprites.js +50 -0
- package/dist/cjs/sprites.js.map +1 -0
- package/dist/cjs/utils.d.ts +2 -5
- package/dist/cjs/utils.js +9 -19
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/baseConfig.js +13 -28
- package/dist/esm/baseConfig.js.map +1 -1
- package/dist/esm/sprites.d.ts +4 -0
- package/dist/esm/sprites.js +44 -0
- package/dist/esm/sprites.js.map +1 -0
- package/dist/esm/utils.d.ts +2 -5
- package/dist/esm/utils.js +6 -18
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/baseConfig.js
CHANGED
|
@@ -5,55 +5,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.baseConfig = void 0;
|
|
7
7
|
const vite_plugin_typo3_1 = __importDefault(require("vite-plugin-typo3"));
|
|
8
|
-
const
|
|
9
|
-
// Plugins
|
|
10
|
-
const vite_plugin_svg_spritemap_1 = __importDefault(require("@spiriit/vite-plugin-svg-spritemap"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
9
|
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
12
10
|
const cssnano_1 = __importDefault(require("cssnano"));
|
|
13
11
|
// @ts-ignore postcss-custom-media doesn't provide types
|
|
14
12
|
const postcss_custom_media_1 = __importDefault(require("postcss-custom-media"));
|
|
15
13
|
// @ts-ignore postcss-sort-media-queries doesn't provide types
|
|
16
14
|
const postcss_sort_media_queries_1 = __importDefault(require("postcss-sort-media-queries"));
|
|
17
|
-
|
|
18
|
-
const utils_js_1 = require("./utils.js");
|
|
15
|
+
const sprites_js_1 = require("./sprites.js");
|
|
19
16
|
exports.baseConfig = {
|
|
17
|
+
build: {
|
|
18
|
+
rollupOptions: {
|
|
19
|
+
input: {},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
20
22
|
plugins: [
|
|
21
23
|
(0, vite_plugin_typo3_1.default)(),
|
|
22
|
-
|
|
23
|
-
injectSvgOnDev: true,
|
|
24
|
-
styles: {
|
|
25
|
-
lang: 'scss',
|
|
26
|
-
filename: './app/sites/site_package/Resources/Private/Css/src/_sprite.scss',
|
|
27
|
-
include: ['mixin', 'variables'],
|
|
28
|
-
names: {
|
|
29
|
-
mixin: 'viteSprite',
|
|
30
|
-
},
|
|
31
|
-
callback: ({ content }) => {
|
|
32
|
-
const BODY_SIZE = 16;
|
|
33
|
-
content = content.replace(/(?:width|height):\s*(\d+)px/g, (match, p1) => {
|
|
34
|
-
// Divide the captured number by 16 and format to 2 decimal places
|
|
35
|
-
const valueInEm = (p1 / BODY_SIZE).toFixed(2);
|
|
36
|
-
// Return the new string with 'em'
|
|
37
|
-
return `${match.split(':')[0]}: ${valueInEm}em`;
|
|
38
|
-
});
|
|
39
|
-
return content;
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
(0, utils_js_1.fixSpritemapPathPlugin)(),
|
|
24
|
+
...sprites_js_1.spritemaps,
|
|
44
25
|
],
|
|
45
26
|
resolve: {
|
|
46
27
|
alias: {
|
|
28
|
+
// Resolve '@' to app/sites
|
|
29
|
+
'@/': node_path_1.default.resolve('app/sites') + '/',
|
|
47
30
|
// Resolve TYPO3 extension imports like "liquidlight/foundation/..." into vendor dir
|
|
48
|
-
liquidlight:
|
|
31
|
+
liquidlight: node_path_1.default.resolve('vendor/liquidlight'),
|
|
49
32
|
},
|
|
50
33
|
},
|
|
51
34
|
css: {
|
|
52
35
|
preprocessorOptions: {
|
|
53
36
|
scss: {
|
|
54
|
-
|
|
37
|
+
loadPaths: [
|
|
55
38
|
// Allow Sass imports from Composer-installed TYPO3 site packages
|
|
56
|
-
|
|
39
|
+
node_path_1.default.resolve('vendor'),
|
|
40
|
+
// Allow sass imports accross sites
|
|
41
|
+
node_path_1.default.resolve('.'),
|
|
57
42
|
],
|
|
58
43
|
}
|
|
59
44
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseConfig.js","sourceRoot":"","sources":["../../src/baseConfig.ts"],"names":[],"mappings":";;;;;;AAEA,0EAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"baseConfig.js","sourceRoot":"","sources":["../../src/baseConfig.ts"],"names":[],"mappings":";;;;;;AAEA,0EAAsC;AACtC,0DAA6B;AAC7B,gEAAwC;AACxC,sDAA8B;AAC9B,wDAAwD;AACxD,gFAAsD;AACtD,8DAA8D;AAC9D,4FAAiE;AAEjE,6CAA0C;AAE7B,QAAA,UAAU,GAAe;IACrC,KAAK,EAAE;QACN,aAAa,EAAE;YACd,KAAK,EAAE,EAAE;SACT;KACD;IACD,OAAO,EAAE;QACR,IAAA,2BAAK,GAAE;QACP,GAAG,uBAAU;KACb;IACD,OAAO,EAAE;QACR,KAAK,EAAE;YACN,2BAA2B;YAC3B,IAAI,EAAE,mBAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,GAAG;YACrC,oFAAoF;YACpF,WAAW,EAAE,mBAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;SAC/C;KACD;IACD,GAAG,EAAE;QACJ,mBAAmB,EAAE;YACpB,IAAI,EAAE;gBACL,SAAS,EAAE;oBACV,iEAAiE;oBACjE,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;oBACtB,mCAAmC;oBACnC,mBAAI,CAAC,OAAO,CAAC,GAAG,CAAC;iBACjB;aACD;SACD;QACD,OAAO,EAAE;YACR,OAAO,EAAE;gBACR,IAAA,sBAAY,GAAE;gBACd,IAAA,8BAAkB,GAAE;gBACpB,IAAA,oCAAuB,GAAE;gBACzB,IAAA,iBAAO,EAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;aAC9B;SACD;KACD;CACD,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.spritemaps = void 0;
|
|
7
|
+
exports.fixSpritemapPathPlugin = fixSpritemapPathPlugin;
|
|
8
|
+
const vite_plugin_svg_spritemap_1 = __importDefault(require("@spiriit/vite-plugin-svg-spritemap"));
|
|
9
|
+
const utils_js_1 = require("./utils.js");
|
|
10
|
+
const BODY_SIZE = 16;
|
|
11
|
+
function fixSpritemapPathPlugin() {
|
|
12
|
+
return [{
|
|
13
|
+
name: 'fix-spritemap-path',
|
|
14
|
+
apply: 'build',
|
|
15
|
+
enforce: 'post',
|
|
16
|
+
generateBundle(_, bundle) {
|
|
17
|
+
const spritemapRegex = /url\((["']?)\/assets\/spritemap([^"')]+)\1\)/g;
|
|
18
|
+
for (const asset of Object.values(bundle)) {
|
|
19
|
+
if (asset.type !== 'asset' || !asset.fileName.endsWith('.css') || typeof asset.source !== 'string') {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
asset.source = asset.source.replace(spritemapRegex, 'url($1spritemap$2$1)');
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
}];
|
|
26
|
+
}
|
|
27
|
+
exports.spritemaps = [
|
|
28
|
+
...(0, utils_js_1.getSites)().flatMap(site => (0, vite_plugin_svg_spritemap_1.default)(`./app/sites/${site}/Resources/Private/Sprite/*.svg`, {
|
|
29
|
+
output: `spritemap-${site}.svg`,
|
|
30
|
+
route: `spritemap-${site}`,
|
|
31
|
+
injectSvgOnDev: true,
|
|
32
|
+
styles: {
|
|
33
|
+
lang: 'scss',
|
|
34
|
+
filename: `./app/sites/${site}/Resources/Private/Css/src/_sprite.scss`,
|
|
35
|
+
include: ['mixin', 'variables'],
|
|
36
|
+
names: {
|
|
37
|
+
mixin: 'viteSprite',
|
|
38
|
+
},
|
|
39
|
+
callback: ({ content }) => {
|
|
40
|
+
content = content.replace(/(?:width|height):\s*(\d+(?:\.\d+)?)px/g, (match, p1) => {
|
|
41
|
+
const valueInEm = (Number(p1) / BODY_SIZE).toFixed(2);
|
|
42
|
+
return `${match.split(':')[0]}: ${valueInEm}em`;
|
|
43
|
+
});
|
|
44
|
+
return content;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
})),
|
|
48
|
+
...fixSpritemapPathPlugin(),
|
|
49
|
+
];
|
|
50
|
+
//# sourceMappingURL=sprites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sprites.js","sourceRoot":"","sources":["../../src/sprites.ts"],"names":[],"mappings":";;;;;;AAyBS,wDAAsB;AAxB/B,mGAAwE;AACxE,yCAAsC;AAEtC,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,SAAS,sBAAsB;IAC9B,OAAO,CAAC;YACP,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,MAAM;YACf,cAAc,CAAC,CAAC,EAAE,MAAM;gBACvB,MAAM,cAAc,GAAG,+CAA+C,CAAC;gBAEvE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;wBACpG,SAAS;oBACV,CAAC;oBAED,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;gBAC7E,CAAC;YACF,CAAC;SACD,CAAC,CAAA;AACH,CAAC;AAIY,QAAA,UAAU,GAAG;IACzB,GAAG,IAAA,mBAAQ,GAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAC5B,IAAA,mCAAsB,EAAC,eAAe,IAAI,iCAAiC,EAAE;QAC5E,MAAM,EAAE,aAAa,IAAI,MAAM;QAC/B,KAAK,EAAE,aAAa,IAAI,EAAE;QAC1B,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,eAAe,IAAI,yCAAyC;YACtE,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;YAC/B,KAAK,EAAE;gBACN,KAAK,EAAE,YAAY;aACnB;YACD,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;gBACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,wCAAwC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;oBACjF,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBACtD,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC;gBACjD,CAAC,CAAC,CAAC;gBACH,OAAO,OAAO,CAAC;YAChB,CAAC;SACD;KACD,CAAC,CACF;IACD,GAAG,sBAAsB,EAAE;CAC3B,CAAC"}
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { PluginOption } from "vite";
|
|
2
1
|
import type { PlainObject } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare function fixSpritemapPathPlugin(): PluginOption[];
|
|
2
|
+
export { fixSpritemapPathPlugin } from './sprites.js';
|
|
3
|
+
export declare function getSites(): string[];
|
|
7
4
|
export declare function deepMerge<T extends PlainObject>(target: T, ...sources: PlainObject[]): T;
|
|
8
5
|
export declare function isObject(item: any): item is PlainObject;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fixSpritemapPathPlugin =
|
|
3
|
+
exports.fixSpritemapPathPlugin = void 0;
|
|
4
|
+
exports.getSites = getSites;
|
|
4
5
|
exports.deepMerge = deepMerge;
|
|
5
6
|
exports.isObject = isObject;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
enforce: 'post',
|
|
14
|
-
generateBundle(_, bundle) {
|
|
15
|
-
const spritemapRegex = /url\((["']?)\/assets\/spritemap([^"')]+)\1\)/g;
|
|
16
|
-
for (const asset of Object.values(bundle)) {
|
|
17
|
-
if (asset.type !== 'asset' || !asset.fileName.endsWith('.css') || typeof asset.source !== 'string') {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
asset.source = asset.source.replace(spritemapRegex, 'url($1spritemap$2$1)');
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
}];
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
// Moved to sprites.ts — re-exported here for backwards compatibility
|
|
9
|
+
var sprites_js_1 = require("./sprites.js");
|
|
10
|
+
Object.defineProperty(exports, "fixSpritemapPathPlugin", { enumerable: true, get: function () { return sprites_js_1.fixSpritemapPathPlugin; } });
|
|
11
|
+
function getSites() {
|
|
12
|
+
return (0, node_fs_1.readdirSync)('./app/sites')
|
|
13
|
+
.filter(name => (0, node_fs_1.existsSync)(`./app/sites/${name}/Configuration/ViteEntrypoints.json`));
|
|
24
14
|
}
|
|
25
15
|
// Allow deep merging of objects
|
|
26
16
|
function deepMerge(target, ...sources) {
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAQA,4BAGC;AAGD,8BAgBC;AAGD,4BAEC;AAnCD,qCAAkD;AAKlD,qEAAqE;AACrE,2CAAsD;AAA7C,oHAAA,sBAAsB,OAAA;AAE/B,SAAgB,QAAQ;IACvB,OAAO,IAAA,qBAAW,EAAC,aAAa,CAAC;SAC/B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,oBAAU,EAAC,eAAe,IAAI,qCAAqC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,gCAAgC;AAChC,SAAgB,SAAS,CAAwB,MAAS,EAAE,GAAG,OAAsB;IACpF,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAiB,CAAC;IAE9C,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAC1B,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvD,SAAS,CAAC,MAAM,CAAC,GAAG,CAAgB,EAAE,MAAM,CAAC,GAAG,CAAgB,CAAC,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,oCAAoC;AACpC,SAAgB,QAAQ,CAAC,IAAS;IACjC,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/esm/baseConfig.js
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
1
|
import typo3 from "vite-plugin-typo3";
|
|
2
|
-
import path from "path";
|
|
3
|
-
// Plugins
|
|
4
|
-
import VitePluginSvgSpritemap from '@spiriit/vite-plugin-svg-spritemap';
|
|
2
|
+
import path from "node:path";
|
|
5
3
|
import autoprefixer from 'autoprefixer';
|
|
6
4
|
import cssnano from 'cssnano';
|
|
7
5
|
// @ts-ignore postcss-custom-media doesn't provide types
|
|
8
6
|
import postcssCustomMedia from 'postcss-custom-media';
|
|
9
7
|
// @ts-ignore postcss-sort-media-queries doesn't provide types
|
|
10
8
|
import postcssSortMediaQueries from 'postcss-sort-media-queries';
|
|
11
|
-
|
|
12
|
-
import { fixSpritemapPathPlugin } from './utils.js';
|
|
9
|
+
import { spritemaps } from './sprites.js';
|
|
13
10
|
export const baseConfig = {
|
|
11
|
+
build: {
|
|
12
|
+
rollupOptions: {
|
|
13
|
+
input: {},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
14
16
|
plugins: [
|
|
15
17
|
typo3(),
|
|
16
|
-
|
|
17
|
-
injectSvgOnDev: true,
|
|
18
|
-
styles: {
|
|
19
|
-
lang: 'scss',
|
|
20
|
-
filename: './app/sites/site_package/Resources/Private/Css/src/_sprite.scss',
|
|
21
|
-
include: ['mixin', 'variables'],
|
|
22
|
-
names: {
|
|
23
|
-
mixin: 'viteSprite',
|
|
24
|
-
},
|
|
25
|
-
callback: ({ content }) => {
|
|
26
|
-
const BODY_SIZE = 16;
|
|
27
|
-
content = content.replace(/(?:width|height):\s*(\d+)px/g, (match, p1) => {
|
|
28
|
-
// Divide the captured number by 16 and format to 2 decimal places
|
|
29
|
-
const valueInEm = (p1 / BODY_SIZE).toFixed(2);
|
|
30
|
-
// Return the new string with 'em'
|
|
31
|
-
return `${match.split(':')[0]}: ${valueInEm}em`;
|
|
32
|
-
});
|
|
33
|
-
return content;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
fixSpritemapPathPlugin(),
|
|
18
|
+
...spritemaps,
|
|
38
19
|
],
|
|
39
20
|
resolve: {
|
|
40
21
|
alias: {
|
|
22
|
+
// Resolve '@' to app/sites
|
|
23
|
+
'@/': path.resolve('app/sites') + '/',
|
|
41
24
|
// Resolve TYPO3 extension imports like "liquidlight/foundation/..." into vendor dir
|
|
42
25
|
liquidlight: path.resolve('vendor/liquidlight'),
|
|
43
26
|
},
|
|
@@ -45,9 +28,11 @@ export const baseConfig = {
|
|
|
45
28
|
css: {
|
|
46
29
|
preprocessorOptions: {
|
|
47
30
|
scss: {
|
|
48
|
-
|
|
31
|
+
loadPaths: [
|
|
49
32
|
// Allow Sass imports from Composer-installed TYPO3 site packages
|
|
50
33
|
path.resolve('vendor'),
|
|
34
|
+
// Allow sass imports accross sites
|
|
35
|
+
path.resolve('.'),
|
|
51
36
|
],
|
|
52
37
|
}
|
|
53
38
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseConfig.js","sourceRoot":"","sources":["../../src/baseConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"baseConfig.js","sourceRoot":"","sources":["../../src/baseConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,wDAAwD;AACxD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,8DAA8D;AAC9D,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAe;IACrC,KAAK,EAAE;QACN,aAAa,EAAE;YACd,KAAK,EAAE,EAAE;SACT;KACD;IACD,OAAO,EAAE;QACR,KAAK,EAAE;QACP,GAAG,UAAU;KACb;IACD,OAAO,EAAE;QACR,KAAK,EAAE;YACN,2BAA2B;YAC3B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,GAAG;YACrC,oFAAoF;YACpF,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;SAC/C;KACD;IACD,GAAG,EAAE;QACJ,mBAAmB,EAAE;YACpB,IAAI,EAAE;gBACL,SAAS,EAAE;oBACV,iEAAiE;oBACjE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;oBACtB,mCAAmC;oBACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;iBACjB;aACD;SACD;QACD,OAAO,EAAE;YACR,OAAO,EAAE;gBACR,YAAY,EAAE;gBACd,kBAAkB,EAAE;gBACpB,uBAAuB,EAAE;gBACzB,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;aAC9B;SACD;KACD;CACD,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import VitePluginSvgSpritemap from '@spiriit/vite-plugin-svg-spritemap';
|
|
2
|
+
import { getSites } from './utils.js';
|
|
3
|
+
const BODY_SIZE = 16;
|
|
4
|
+
function fixSpritemapPathPlugin() {
|
|
5
|
+
return [{
|
|
6
|
+
name: 'fix-spritemap-path',
|
|
7
|
+
apply: 'build',
|
|
8
|
+
enforce: 'post',
|
|
9
|
+
generateBundle(_, bundle) {
|
|
10
|
+
const spritemapRegex = /url\((["']?)\/assets\/spritemap([^"')]+)\1\)/g;
|
|
11
|
+
for (const asset of Object.values(bundle)) {
|
|
12
|
+
if (asset.type !== 'asset' || !asset.fileName.endsWith('.css') || typeof asset.source !== 'string') {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
asset.source = asset.source.replace(spritemapRegex, 'url($1spritemap$2$1)');
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
}];
|
|
19
|
+
}
|
|
20
|
+
export { fixSpritemapPathPlugin };
|
|
21
|
+
export const spritemaps = [
|
|
22
|
+
...getSites().flatMap(site => VitePluginSvgSpritemap(`./app/sites/${site}/Resources/Private/Sprite/*.svg`, {
|
|
23
|
+
output: `spritemap-${site}.svg`,
|
|
24
|
+
route: `spritemap-${site}`,
|
|
25
|
+
injectSvgOnDev: true,
|
|
26
|
+
styles: {
|
|
27
|
+
lang: 'scss',
|
|
28
|
+
filename: `./app/sites/${site}/Resources/Private/Css/src/_sprite.scss`,
|
|
29
|
+
include: ['mixin', 'variables'],
|
|
30
|
+
names: {
|
|
31
|
+
mixin: 'viteSprite',
|
|
32
|
+
},
|
|
33
|
+
callback: ({ content }) => {
|
|
34
|
+
content = content.replace(/(?:width|height):\s*(\d+(?:\.\d+)?)px/g, (match, p1) => {
|
|
35
|
+
const valueInEm = (Number(p1) / BODY_SIZE).toFixed(2);
|
|
36
|
+
return `${match.split(':')[0]}: ${valueInEm}em`;
|
|
37
|
+
});
|
|
38
|
+
return content;
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
})),
|
|
42
|
+
...fixSpritemapPathPlugin(),
|
|
43
|
+
];
|
|
44
|
+
//# sourceMappingURL=sprites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sprites.js","sourceRoot":"","sources":["../../src/sprites.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,SAAS,sBAAsB;IAC9B,OAAO,CAAC;YACP,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,MAAM;YACf,cAAc,CAAC,CAAC,EAAE,MAAM;gBACvB,MAAM,cAAc,GAAG,+CAA+C,CAAC;gBAEvE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;wBACpG,SAAS;oBACV,CAAC;oBAED,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;gBAC7E,CAAC;YACF,CAAC;SACD,CAAC,CAAA;AACH,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAC5B,sBAAsB,CAAC,eAAe,IAAI,iCAAiC,EAAE;QAC5E,MAAM,EAAE,aAAa,IAAI,MAAM;QAC/B,KAAK,EAAE,aAAa,IAAI,EAAE;QAC1B,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,eAAe,IAAI,yCAAyC;YACtE,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;YAC/B,KAAK,EAAE;gBACN,KAAK,EAAE,YAAY;aACnB;YACD,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;gBACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,wCAAwC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;oBACjF,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBACtD,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC;gBACjD,CAAC,CAAC,CAAC;gBACH,OAAO,OAAO,CAAC;YAChB,CAAC;SACD;KACD,CAAC,CACF;IACD,GAAG,sBAAsB,EAAE;CAC3B,CAAC"}
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { PluginOption } from "vite";
|
|
2
1
|
import type { PlainObject } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare function fixSpritemapPathPlugin(): PluginOption[];
|
|
2
|
+
export { fixSpritemapPathPlugin } from './sprites.js';
|
|
3
|
+
export declare function getSites(): string[];
|
|
7
4
|
export declare function deepMerge<T extends PlainObject>(target: T, ...sources: PlainObject[]): T;
|
|
8
5
|
export declare function isObject(item: any): item is PlainObject;
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
apply: 'build',
|
|
8
|
-
enforce: 'post',
|
|
9
|
-
generateBundle(_, bundle) {
|
|
10
|
-
const spritemapRegex = /url\((["']?)\/assets\/spritemap([^"')]+)\1\)/g;
|
|
11
|
-
for (const asset of Object.values(bundle)) {
|
|
12
|
-
if (asset.type !== 'asset' || !asset.fileName.endsWith('.css') || typeof asset.source !== 'string') {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
asset.source = asset.source.replace(spritemapRegex, 'url($1spritemap$2$1)');
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
}];
|
|
1
|
+
import { readdirSync, existsSync } from 'node:fs';
|
|
2
|
+
// Moved to sprites.ts — re-exported here for backwards compatibility
|
|
3
|
+
export { fixSpritemapPathPlugin } from './sprites.js';
|
|
4
|
+
export function getSites() {
|
|
5
|
+
return readdirSync('./app/sites')
|
|
6
|
+
.filter(name => existsSync(`./app/sites/${name}/Configuration/ViteEntrypoints.json`));
|
|
19
7
|
}
|
|
20
8
|
// Allow deep merging of objects
|
|
21
9
|
export function deepMerge(target, ...sources) {
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAKlD,qEAAqE;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,UAAU,QAAQ;IACvB,OAAO,WAAW,CAAC,aAAa,CAAC;SAC/B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,IAAI,qCAAqC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,gCAAgC;AAChC,MAAM,UAAU,SAAS,CAAwB,MAAS,EAAE,GAAG,OAAsB;IACpF,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAiB,CAAC;IAE9C,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAC1B,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvD,SAAS,CAAC,MAAM,CAAC,GAAG,CAAgB,EAAE,MAAM,CAAC,GAAG,CAAgB,CAAC,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,QAAQ,CAAC,IAAS;IACjC,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC"}
|