@absolu/assets-toolkit 1.0.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/README.md +185 -0
- package/dist/create-config.d.ts +3 -0
- package/dist/create-config.d.ts.map +1 -0
- package/dist/create-config.js +147 -0
- package/dist/create-config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/iconfont/BuildFont.d.ts +19 -0
- package/dist/plugins/iconfont/BuildFont.d.ts.map +1 -0
- package/dist/plugins/iconfont/BuildFont.js +80 -0
- package/dist/plugins/iconfont/BuildFont.js.map +1 -0
- package/dist/plugins/iconfont/Cache.d.ts +19 -0
- package/dist/plugins/iconfont/Cache.d.ts.map +1 -0
- package/dist/plugins/iconfont/Cache.js +54 -0
- package/dist/plugins/iconfont/Cache.js.map +1 -0
- package/dist/plugins/iconfont/Logger.d.ts +2 -0
- package/dist/plugins/iconfont/Logger.d.ts.map +1 -0
- package/dist/plugins/iconfont/Logger.js +5 -0
- package/dist/plugins/iconfont/Logger.js.map +1 -0
- package/dist/plugins/iconfont/VitePluginIconfont.d.ts +4 -0
- package/dist/plugins/iconfont/VitePluginIconfont.d.ts.map +1 -0
- package/dist/plugins/iconfont/VitePluginIconfont.js +62 -0
- package/dist/plugins/iconfont/VitePluginIconfont.js.map +1 -0
- package/dist/plugins/iconfont/templates/iconfonts-vars.njk +23 -0
- package/dist/plugins/iconfont/templates/iconfonts.njk +21 -0
- package/dist/plugins/svgstore/BuildSpriteFile.d.ts +6 -0
- package/dist/plugins/svgstore/BuildSpriteFile.d.ts.map +1 -0
- package/dist/plugins/svgstore/BuildSpriteFile.js +74 -0
- package/dist/plugins/svgstore/BuildSpriteFile.js.map +1 -0
- package/dist/plugins/svgstore/Logger.d.ts +2 -0
- package/dist/plugins/svgstore/Logger.d.ts.map +1 -0
- package/dist/plugins/svgstore/Logger.js +5 -0
- package/dist/plugins/svgstore/Logger.js.map +1 -0
- package/dist/plugins/svgstore/VitePluginSvgstore.d.ts +4 -0
- package/dist/plugins/svgstore/VitePluginSvgstore.d.ts.map +1 -0
- package/dist/plugins/svgstore/VitePluginSvgstore.js +39 -0
- package/dist/plugins/svgstore/VitePluginSvgstore.js.map +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# @absolu/assets-toolkit
|
|
2
|
+
|
|
3
|
+
Toolkit Vite pour les pipelines d'assets front-end. Fournit une **factory de configuration Vite** et deux **plugins Vite** (iconfont & svgstore), pensés pour les projets utilisant Vite avec SCSS (typiquement des thèmes Drupal ou CMS).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @absolu/assets-toolkit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer dependencies
|
|
12
|
+
|
|
13
|
+
| Paquet | Requis |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `vite` >= 5.0.0 | oui |
|
|
16
|
+
| `sass` >= 1.0.0 | oui |
|
|
17
|
+
| `vite-plugin-imagemin` >= 0.6.0 | optionnel |
|
|
18
|
+
| `vite-plugin-live-reload` >= 3.0.0 | optionnel |
|
|
19
|
+
|
|
20
|
+
## Utilisation rapide
|
|
21
|
+
|
|
22
|
+
Créez un fichier `vite.config.ts` à la racine de votre projet :
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createViteConfig } from '@absolu/assets-toolkit'
|
|
26
|
+
import localConfig from './config.json' with { type: 'json' }
|
|
27
|
+
|
|
28
|
+
export default createViteConfig({
|
|
29
|
+
base: '/themes/custom/mon-theme/assets',
|
|
30
|
+
localConfig,
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
C'est tout. Tous les plugins (iconfont, svgstore, live reload) sont **activés par défaut** avec des valeurs sensibles. Vous pouvez les personnaliser ou les désactiver individuellement (voir API ci-dessous).
|
|
35
|
+
|
|
36
|
+
Le fichier `config.json` (non versionné) contient uniquement la configuration locale, propre à chaque machine :
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"server": {
|
|
41
|
+
"https": {
|
|
42
|
+
"key": "/chemin/vers/localhost-key.pem",
|
|
43
|
+
"cert": "/chemin/vers/localhost.pem"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### `createViteConfig(options)`
|
|
52
|
+
|
|
53
|
+
Factory qui produit une configuration Vite complète avec des valeurs par défaut sensibles (globs d'entrée, chemins de sortie, alias, plugins).
|
|
54
|
+
|
|
55
|
+
| Option | Type | Défaut | Description |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `base` | `string` | — | **Requis.** Chemin de base pour le serveur de dev (ex. `/themes/custom/mon-theme/assets`) |
|
|
58
|
+
| `localConfig` | `LocalConfig` | — | Configuration locale non versionnée (certificats HTTPS) |
|
|
59
|
+
| `iconfont` | `IconfontOptions \| false` | `{}` (activé) | Options du plugin iconfont. `false` pour désactiver |
|
|
60
|
+
| `svgstore` | `SvgstoreOptions \| false` | `{}` (activé) | Options du plugin svgstore. `false` pour désactiver |
|
|
61
|
+
| `imagemin` | `boolean` | `true` | Activer le plugin imagemin |
|
|
62
|
+
| `liveReload` | `string[] \| false` | `['../templates/**/*.twig']` | Glob patterns pour le live reload. `false` pour désactiver |
|
|
63
|
+
| `entries` | `string[]` | voir ci-dessous | Glob patterns des fichiers d'entrée |
|
|
64
|
+
| `entriesIgnore` | `string[]` | voir ci-dessous | Patterns à exclure |
|
|
65
|
+
| `manualChunks` | `(id: string) => string \| undefined` | — | Définition des manual chunks |
|
|
66
|
+
| `plugins` | `Plugin[]` | — | Plugins Vite supplémentaires |
|
|
67
|
+
|
|
68
|
+
#### `localConfig`
|
|
69
|
+
|
|
70
|
+
Configuration locale, typiquement chargée depuis un `config.json` non versionné.
|
|
71
|
+
|
|
72
|
+
| Propriété | Type | Description |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `server.https.key` | `string` | Chemin vers le fichier clé privée du certificat SSL |
|
|
75
|
+
| `server.https.cert` | `string` | Chemin vers le fichier certificat SSL |
|
|
76
|
+
|
|
77
|
+
#### Valeurs par défaut
|
|
78
|
+
|
|
79
|
+
**Entrées :**
|
|
80
|
+
|
|
81
|
+
- `src/scss/*.scss`
|
|
82
|
+
- `src/scripts/*.{js,ts}`
|
|
83
|
+
- `src/iconfonts/*.{woff2,woff}`
|
|
84
|
+
- `src/images/**/*.{png,jpeg,jpg,gif,svg}`
|
|
85
|
+
|
|
86
|
+
**Exclusions :** `src/images/icons/**/*.svg`, `src/images/icons-sprite/**/*.svg`
|
|
87
|
+
|
|
88
|
+
**Alias :** `@` → `src/`, `@images` → `src/images/`, `@fonts` → `src/fonts/`
|
|
89
|
+
|
|
90
|
+
**Sortie :** `dist/` avec organisation automatique (css, scripts, images, iconfonts, fonts)
|
|
91
|
+
|
|
92
|
+
#### Désactiver des plugins
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
export default createViteConfig({
|
|
96
|
+
base: '/themes/custom/mon-theme/assets',
|
|
97
|
+
iconfont: false, // désactive la génération d'iconfont
|
|
98
|
+
svgstore: false, // désactive la génération du sprite SVG
|
|
99
|
+
liveReload: false, // désactive le live reload
|
|
100
|
+
imagemin: false, // désactive l'optimisation d'images
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Personnaliser des plugins
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
export default createViteConfig({
|
|
108
|
+
base: '/themes/custom/mon-theme/assets',
|
|
109
|
+
localConfig,
|
|
110
|
+
iconfont: {
|
|
111
|
+
svgs: 'src/images/icons/**/*.svg',
|
|
112
|
+
fontName: 'iconfont',
|
|
113
|
+
scssDir: 'src/scss/base/iconfonts',
|
|
114
|
+
iconClassName: 'icon',
|
|
115
|
+
fontPath: '@/iconfonts/',
|
|
116
|
+
},
|
|
117
|
+
svgstore: {
|
|
118
|
+
srcDir: 'src/images/icons-sprite',
|
|
119
|
+
targetFile: 'src/images/sprite.svg',
|
|
120
|
+
symbolId: '[name]',
|
|
121
|
+
},
|
|
122
|
+
liveReload: ['../templates/**/*.twig'],
|
|
123
|
+
imagemin: true,
|
|
124
|
+
entries: [
|
|
125
|
+
'src/scss/*.scss',
|
|
126
|
+
'src/scripts/*.js',
|
|
127
|
+
'src/scripts/*.ts',
|
|
128
|
+
'src/iconfonts/*.{woff2,woff}',
|
|
129
|
+
'src/images/**/*.{png,jpeg,jpg,gif,svg}',
|
|
130
|
+
],
|
|
131
|
+
entriesIgnore: [
|
|
132
|
+
'src/images/icons/**/*.svg',
|
|
133
|
+
'src/images/icons-sprite/**/*.svg',
|
|
134
|
+
],
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### `VitePluginIconfont(options)`
|
|
139
|
+
|
|
140
|
+
Plugin Vite qui convertit des icônes SVG en font (SVG → TTF → WOFF/WOFF2) et génère les fichiers SCSS correspondants via des templates Nunjucks. Inclut un cache basé sur le hash des fichiers sources pour éviter les rebuilds inutiles.
|
|
141
|
+
|
|
142
|
+
| Option | Type | Défaut | Description |
|
|
143
|
+
|---|---|---|---|
|
|
144
|
+
| `svgs` | `string` | `src/images/icons/**/*.svg` | Glob pattern des fichiers SVG sources |
|
|
145
|
+
| `fontName` | `string` | `iconfont` | Nom de la font générée |
|
|
146
|
+
| `scssDir` | `string` | `src/scss/base/iconfonts` | Dossier de sortie des fichiers SCSS |
|
|
147
|
+
| `iconClassName` | `string` | `icon` | Nom de la classe CSS de base |
|
|
148
|
+
| `fontPath` | `string` | `@/iconfonts/` | Chemin relatif vers la font dans le CSS |
|
|
149
|
+
|
|
150
|
+
### `VitePluginSvgstore(options)`
|
|
151
|
+
|
|
152
|
+
Plugin Vite qui fusionne des fichiers SVG en un sprite SVG unique, optimisé avec SVGO.
|
|
153
|
+
|
|
154
|
+
| Option | Type | Défaut | Description |
|
|
155
|
+
|---|---|---|---|
|
|
156
|
+
| `srcDir` | `string` | `src/images/icons-sprite` | Dossier source des SVG |
|
|
157
|
+
| `targetFile` | `string` | `src/images/sprite.svg` | Fichier de sortie du sprite |
|
|
158
|
+
| `symbolId` | `string` | `[name]` | Pattern pour l'id des symboles (`[name]` sera remplacé) |
|
|
159
|
+
|
|
160
|
+
## Utilisation standalone des plugins
|
|
161
|
+
|
|
162
|
+
Les plugins peuvent être utilisés indépendamment de la factory :
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { VitePluginIconfont, VitePluginSvgstore } from '@absolu/assets-toolkit'
|
|
166
|
+
import { defineConfig } from 'vite'
|
|
167
|
+
|
|
168
|
+
export default defineConfig({
|
|
169
|
+
plugins: [
|
|
170
|
+
VitePluginIconfont({
|
|
171
|
+
fontName: 'my-icons',
|
|
172
|
+
scssDir: 'src/scss/icons',
|
|
173
|
+
iconClassName: 'icon',
|
|
174
|
+
}),
|
|
175
|
+
VitePluginSvgstore({
|
|
176
|
+
srcDir: 'src/sprites',
|
|
177
|
+
symbolId: 'icon-[name]',
|
|
178
|
+
}),
|
|
179
|
+
],
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Licence
|
|
184
|
+
|
|
185
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../src/create-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAwBxD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,6BAsIhE"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { resolve, dirname } from 'path';
|
|
2
|
+
import { globSync } from 'glob';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import VitePluginIconfont from './plugins/iconfont/VitePluginIconfont.js';
|
|
5
|
+
import VitePluginSvgstore from './plugins/svgstore/VitePluginSvgstore.js';
|
|
6
|
+
function getFiles(entries, ignore) {
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const patterns = entries.map(e => resolve(cwd, e));
|
|
9
|
+
const ignorePatterns = ignore.map(e => resolve(cwd, e));
|
|
10
|
+
const files = globSync(patterns, { ignore: ignorePatterns });
|
|
11
|
+
const input = {};
|
|
12
|
+
files.forEach((file) => {
|
|
13
|
+
const nameMatch = file.match(/([^\/]+)\.(js|scss|css|ts|png|jpeg|jpg|gif|svg|woff2|woff)$/);
|
|
14
|
+
if (nameMatch && nameMatch[0]) {
|
|
15
|
+
input[nameMatch[0]] = resolve(cwd, file);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return input;
|
|
19
|
+
}
|
|
20
|
+
export function createViteConfig(options) {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const entries = options.entries ?? [
|
|
23
|
+
'src/scss/*.scss',
|
|
24
|
+
'src/scripts/*.js',
|
|
25
|
+
'src/scripts/*.ts',
|
|
26
|
+
'src/iconfonts/*.{woff2,woff}',
|
|
27
|
+
'src/images/**/*.{png,jpeg,jpg,gif,svg}',
|
|
28
|
+
];
|
|
29
|
+
const entriesIgnore = options.entriesIgnore ?? [
|
|
30
|
+
'src/images/icons/**/*.svg',
|
|
31
|
+
'src/images/icons-sprite/**/*.svg',
|
|
32
|
+
];
|
|
33
|
+
// Construction des plugins
|
|
34
|
+
const plugins = [];
|
|
35
|
+
// Live reload
|
|
36
|
+
if (options.liveReload !== false) {
|
|
37
|
+
const liveReloadPatterns = options.liveReload ?? ['../templates/**/*.twig'];
|
|
38
|
+
try {
|
|
39
|
+
const { default: LiveReloadPlugin } = require('vite-plugin-live-reload');
|
|
40
|
+
plugins.push(LiveReloadPlugin(liveReloadPatterns.map(p => resolve(cwd, p))));
|
|
41
|
+
}
|
|
42
|
+
catch { /* peer dep non installée */ }
|
|
43
|
+
}
|
|
44
|
+
// Imagemin (optionnel)
|
|
45
|
+
if (options.imagemin !== false) {
|
|
46
|
+
try {
|
|
47
|
+
const { default: ImageminPlugin } = require('vite-plugin-imagemin');
|
|
48
|
+
plugins.push(ImageminPlugin({
|
|
49
|
+
filter: (file) => /\.(png|jpe?g|gif|tiff|webp)$/i.test(file),
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
catch { /* peer dep non installée */ }
|
|
53
|
+
}
|
|
54
|
+
// Iconfont
|
|
55
|
+
if (options.iconfont !== false) {
|
|
56
|
+
const iconfontOpts = typeof options.iconfont === 'object' ? options.iconfont : {};
|
|
57
|
+
plugins.push(VitePluginIconfont(iconfontOpts));
|
|
58
|
+
}
|
|
59
|
+
// Svgstore
|
|
60
|
+
if (options.svgstore !== false) {
|
|
61
|
+
const svgstoreOpts = typeof options.svgstore === 'object' ? options.svgstore : {};
|
|
62
|
+
plugins.push(VitePluginSvgstore(svgstoreOpts));
|
|
63
|
+
}
|
|
64
|
+
// Plugins supplémentaires
|
|
65
|
+
if (options.plugins) {
|
|
66
|
+
plugins.push(...options.plugins);
|
|
67
|
+
}
|
|
68
|
+
return defineConfig({
|
|
69
|
+
plugins,
|
|
70
|
+
base: process.env.NODE_ENV === 'production' ? './' : options.base,
|
|
71
|
+
publicDir: 'public',
|
|
72
|
+
root: cwd,
|
|
73
|
+
server: {
|
|
74
|
+
cors: true,
|
|
75
|
+
...(options.localConfig?.server?.https ? { https: options.localConfig.server.https } : {}),
|
|
76
|
+
},
|
|
77
|
+
resolve: {
|
|
78
|
+
alias: {
|
|
79
|
+
'@images': resolve(cwd, 'src/images'),
|
|
80
|
+
'@': resolve(cwd, 'src'),
|
|
81
|
+
'@fonts': resolve(cwd, 'src/fonts'),
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
esbuild: {
|
|
85
|
+
target: 'esnext',
|
|
86
|
+
},
|
|
87
|
+
optimizeDeps: {
|
|
88
|
+
esbuildOptions: {
|
|
89
|
+
target: 'esnext'
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
build: {
|
|
93
|
+
target: 'esnext',
|
|
94
|
+
manifest: true,
|
|
95
|
+
outDir: 'dist',
|
|
96
|
+
copyPublicDir: true,
|
|
97
|
+
rollupOptions: {
|
|
98
|
+
input: getFiles(entries, entriesIgnore),
|
|
99
|
+
output: {
|
|
100
|
+
manualChunks: options.manualChunks,
|
|
101
|
+
chunkFileNames: () => 'scripts/chunks/[name]-[hash].js',
|
|
102
|
+
entryFileNames: (chunkInfo) => {
|
|
103
|
+
const [name, ext] = chunkInfo.name.split('.');
|
|
104
|
+
if (ext === 'ts') {
|
|
105
|
+
return `scripts/${name}.js`;
|
|
106
|
+
}
|
|
107
|
+
return `scripts/[name]`;
|
|
108
|
+
},
|
|
109
|
+
assetFileNames: (assetInfo) => {
|
|
110
|
+
const fileName = assetInfo.names && assetInfo.names.length > 0 ? assetInfo.names[0] : '';
|
|
111
|
+
const fileNameParts = fileName.split('.');
|
|
112
|
+
const ext = fileNameParts[fileNameParts.length - 1] || '';
|
|
113
|
+
if (ext === 'css') {
|
|
114
|
+
return `css/[name].css`;
|
|
115
|
+
}
|
|
116
|
+
if (['png', 'jpg', 'jpeg', 'gif', 'svg'].includes(ext)) {
|
|
117
|
+
const originalPath = assetInfo.originalFileNames && assetInfo.originalFileNames.length > 0
|
|
118
|
+
? assetInfo.originalFileNames[0]
|
|
119
|
+
: '';
|
|
120
|
+
if (originalPath && originalPath.includes('src/images/')) {
|
|
121
|
+
const relativePath = originalPath.split('src/images/').pop() || '';
|
|
122
|
+
const destPath = dirname(relativePath);
|
|
123
|
+
if (assetInfo.names[0].includes('sprite')) {
|
|
124
|
+
return 'images/[name]-[hash].[ext]';
|
|
125
|
+
}
|
|
126
|
+
return `images/${destPath}/[name].[ext]`;
|
|
127
|
+
}
|
|
128
|
+
if (assetInfo.names[0].includes('sprite')) {
|
|
129
|
+
return 'images/[name]-[hash].[ext]';
|
|
130
|
+
}
|
|
131
|
+
return `images/[name].[ext]`;
|
|
132
|
+
}
|
|
133
|
+
if (['woff2', 'woff'].includes(ext) && assetInfo.originalFileNames[0]?.includes('src/iconfonts')) {
|
|
134
|
+
return 'iconfonts/[name].[ext]';
|
|
135
|
+
}
|
|
136
|
+
if (['woff2', 'woff'].includes(ext) && assetInfo.originalFileNames[0]?.includes('src/fonts')) {
|
|
137
|
+
return 'fonts/[name].[ext]';
|
|
138
|
+
}
|
|
139
|
+
return `[name].[ext]`;
|
|
140
|
+
},
|
|
141
|
+
format: 'es'
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=create-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-config.js","sourceRoot":"","sources":["../src/create-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAGlC,OAAO,kBAAkB,MAAM,0CAA0C,CAAC;AAC1E,OAAO,kBAAkB,MAAM,0CAA0C,CAAC;AAM1E,SAAS,QAAQ,CAAC,OAAiB,EAAE,MAAgB;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;I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,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gCACxC,OAAO,4BAA4B,CAAC;4BACxC,CAAC;4BACD,OAAO,qBAAqB,CAAC;wBACjC,CAAC;wBACD,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;4BAC/F,OAAO,wBAAwB,CAAC;wBACpC,CAAC;wBACD,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;4BAC3F,OAAO,oBAAoB,CAAC;wBAChC,CAAC;wBACD,OAAO,cAAc,CAAC;oBAC1B,CAAC;oBACD,MAAM,EAAE,IAAI;iBACf;aACJ;SACJ;KACJ,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createViteConfig } from './create-config.js';
|
|
2
|
+
export { default as VitePluginIconfont } from './plugins/iconfont/VitePluginIconfont.js';
|
|
3
|
+
export { default as VitePluginSvgstore } from './plugins/svgstore/VitePluginSvgstore.js';
|
|
4
|
+
export type { LocalConfig, IconfontOptions, SvgstoreOptions, CreateViteConfigOptions, } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AACzF,YAAY,EACR,WAAW,EACX,eAAe,EACf,eAAe,EACf,uBAAuB,GAC1B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createViteConfig } from './create-config.js';
|
|
2
|
+
export { default as VitePluginIconfont } from './plugins/iconfont/VitePluginIconfont.js';
|
|
3
|
+
export { default as VitePluginSvgstore } from './plugins/svgstore/VitePluginSvgstore.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,0CAA0C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface BuildFontOptions {
|
|
2
|
+
fontName: string;
|
|
3
|
+
svgs?: string;
|
|
4
|
+
scssDir?: string;
|
|
5
|
+
iconClassName?: string;
|
|
6
|
+
fontPath?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
interface BuildConfig {
|
|
10
|
+
buildFont?: boolean;
|
|
11
|
+
cssCacheToken?: number | null;
|
|
12
|
+
}
|
|
13
|
+
export declare class BuildFont {
|
|
14
|
+
private options;
|
|
15
|
+
constructor(options: BuildFontOptions);
|
|
16
|
+
build(config?: BuildConfig): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=BuildFont.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildFont.d.ts","sourceRoot":"","sources":["../../../src/plugins/iconfont/BuildFont.ts"],"names":[],"mappings":"AAgBA,UAAU,gBAAgB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,UAAU,WAAW;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAWD,qBAAa,SAAS;IAClB,OAAO,CAAC,OAAO,CAAmB;gBAEtB,OAAO,EAAE,gBAAgB;IAI/B,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAoEnD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { resolve, dirname } from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { globSync } from "glob";
|
|
4
|
+
import { createReadStream, createWriteStream, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
5
|
+
import { writeFile } from "fs/promises";
|
|
6
|
+
import SVGIcons2SVGFontStream from "svgicons2svgfont";
|
|
7
|
+
import svg2ttf from "svg2ttf";
|
|
8
|
+
import ttf2woff2 from "ttf2woff2";
|
|
9
|
+
import ttf2woff from "ttf2woff";
|
|
10
|
+
import nunjucks from "nunjucks";
|
|
11
|
+
import { log } from "./Logger.js";
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
export class BuildFont {
|
|
15
|
+
options;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
}
|
|
19
|
+
async build(config) {
|
|
20
|
+
const processConfig = {
|
|
21
|
+
buildFont: true,
|
|
22
|
+
cssCacheToken: null,
|
|
23
|
+
...config
|
|
24
|
+
};
|
|
25
|
+
return await new Promise((resolvePromise) => {
|
|
26
|
+
let unicodeCounter = 0xE001;
|
|
27
|
+
const glyphsData = [];
|
|
28
|
+
const fontStream = new SVGIcons2SVGFontStream({
|
|
29
|
+
fontName: this.options.fontName,
|
|
30
|
+
normalize: true,
|
|
31
|
+
fontHeight: 1000
|
|
32
|
+
});
|
|
33
|
+
const fontSvgPath = resolve(`src/iconfonts/${this.options.fontName}.svg`);
|
|
34
|
+
fontStream.pipe(createWriteStream(fontSvgPath))
|
|
35
|
+
.on('finish', async () => {
|
|
36
|
+
if (processConfig.buildFont) {
|
|
37
|
+
log("Construction de la font d'icônes");
|
|
38
|
+
const content = readFileSync(fontSvgPath);
|
|
39
|
+
const ttf = svg2ttf(content.toString(), {
|
|
40
|
+
ts: 0,
|
|
41
|
+
});
|
|
42
|
+
await writeFile(`src/iconfonts/${this.options.fontName}.woff2`, ttf2woff2(Buffer.from(ttf.buffer)));
|
|
43
|
+
await writeFile(`src/iconfonts/${this.options.fontName}.woff`, ttf2woff(Buffer.from(ttf.buffer)));
|
|
44
|
+
}
|
|
45
|
+
const templatesDir = resolve(__dirname, 'templates');
|
|
46
|
+
const env = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatesDir));
|
|
47
|
+
const css = env.render('iconfonts.njk', {
|
|
48
|
+
glyphs: glyphsData,
|
|
49
|
+
fontName: this.options.fontName,
|
|
50
|
+
fontPath: this.options.fontPath ?? '@/iconfonts/',
|
|
51
|
+
className: this.options.iconClassName ?? 'icon',
|
|
52
|
+
cacheToken: processConfig.cssCacheToken
|
|
53
|
+
});
|
|
54
|
+
const cssVars = env.render('iconfonts-vars.njk', {
|
|
55
|
+
glyphs: glyphsData,
|
|
56
|
+
fontName: this.options.fontName,
|
|
57
|
+
});
|
|
58
|
+
const scssDir = this.options.scssDir ?? 'src/scss/base/iconfonts';
|
|
59
|
+
mkdirSync(resolve(scssDir), { recursive: true });
|
|
60
|
+
writeFileSync(resolve(`${scssDir}/_iconfonts.scss`), css);
|
|
61
|
+
writeFileSync(resolve(`${scssDir}/_iconfonts-vars.scss`), cssVars);
|
|
62
|
+
resolvePromise();
|
|
63
|
+
});
|
|
64
|
+
const files = globSync(this.options.svgs ?? 'src/images/icons/**/*.svg');
|
|
65
|
+
files.forEach(file => {
|
|
66
|
+
const unicodeCounter2 = unicodeCounter++;
|
|
67
|
+
const unicodeChar = String.fromCharCode(unicodeCounter2);
|
|
68
|
+
const glyph = createReadStream(file);
|
|
69
|
+
glyph.metadata = {
|
|
70
|
+
unicode: [unicodeChar],
|
|
71
|
+
name: file.split('/').at(-1).split('.').at(0),
|
|
72
|
+
};
|
|
73
|
+
glyphsData.push(glyph.metadata);
|
|
74
|
+
fontStream.write(glyph);
|
|
75
|
+
});
|
|
76
|
+
fontStream.end();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=BuildFont.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildFont.js","sourceRoot":"","sources":["../../../src/plugins/iconfont/BuildFont.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAa,MAAM,IAAI,CAAC;AAC3G,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,OAAO,sBAAsB,MAAM,kBAAkB,CAAC;AACtD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAEhC,MAAM,UAAU,GAAG,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Ac,EAAE,CAAC;YACrB,CAAC,CAAC,CAAC;YAEP,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,2BAA2B,CAAC,CAAC;YACzE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjB,MAAM,eAAe,GAAG,cAAc,EAAE,CAAC;gBACzC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;gBACzD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAgB,CAAC;gBACpD,KAAK,CAAC,QAAQ,GAAG;oBACb,OAAO,EAAE,CAAC,WAAW,CAAC;oBACtB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE;iBAClD,CAAC;gBACF,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,QAAyB,CAAC,CAAC;gBACjD,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,GAAG,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface CacheData {
|
|
2
|
+
hash?: string;
|
|
3
|
+
cssCacheToken?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class Cache {
|
|
6
|
+
private currentHash;
|
|
7
|
+
private logger;
|
|
8
|
+
private cacheFile;
|
|
9
|
+
constructor(logger: any);
|
|
10
|
+
getCacheData(): CacheData;
|
|
11
|
+
getPreviousHash(): string | null;
|
|
12
|
+
getPreviousCssCacheToken(): number | null;
|
|
13
|
+
setCurrentHash(hash: string): void;
|
|
14
|
+
getFileHash(filePath: string): string;
|
|
15
|
+
getFilesHash(files: string[]): string;
|
|
16
|
+
writeCacheFile(): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=Cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../src/plugins/iconfont/Cache.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,KAAK;IACd,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,GAAG;IAMvB,YAAY,IAAI,SAAS;IAUzB,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC,wBAAwB,IAAI,MAAM,GAAG,IAAI;IAIzC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMrC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IASrC,cAAc,IAAI,IAAI;CAOzB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
+
import { dirname, resolve } from "path";
|
|
4
|
+
import { log } from "./Logger.js";
|
|
5
|
+
export class Cache {
|
|
6
|
+
currentHash;
|
|
7
|
+
logger;
|
|
8
|
+
cacheFile;
|
|
9
|
+
constructor(logger) {
|
|
10
|
+
this.currentHash = '';
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
this.cacheFile = resolve(process.cwd(), '.cache', '.vite-plugin-iconfont.json');
|
|
13
|
+
}
|
|
14
|
+
getCacheData() {
|
|
15
|
+
let cacheData = {};
|
|
16
|
+
try {
|
|
17
|
+
cacheData = JSON.parse(readFileSync(this.cacheFile, 'utf-8'));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
log('Aucun fichier de cache trouvé');
|
|
21
|
+
}
|
|
22
|
+
return cacheData;
|
|
23
|
+
}
|
|
24
|
+
getPreviousHash() {
|
|
25
|
+
return this.getCacheData()?.hash || null;
|
|
26
|
+
}
|
|
27
|
+
getPreviousCssCacheToken() {
|
|
28
|
+
return this.getCacheData()?.cssCacheToken || null;
|
|
29
|
+
}
|
|
30
|
+
setCurrentHash(hash) {
|
|
31
|
+
this.currentHash = hash;
|
|
32
|
+
}
|
|
33
|
+
getFileHash(filePath) {
|
|
34
|
+
const hash = createHash('sha256');
|
|
35
|
+
hash.update(readFileSync(filePath).toString());
|
|
36
|
+
return hash.digest('hex');
|
|
37
|
+
}
|
|
38
|
+
getFilesHash(files) {
|
|
39
|
+
let currentHash = '';
|
|
40
|
+
files.forEach(file => {
|
|
41
|
+
const hash = this.getFileHash(file);
|
|
42
|
+
currentHash += hash;
|
|
43
|
+
});
|
|
44
|
+
return currentHash;
|
|
45
|
+
}
|
|
46
|
+
writeCacheFile() {
|
|
47
|
+
const cacheDir = dirname(this.cacheFile);
|
|
48
|
+
const cssCacheToken = Date.now();
|
|
49
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
50
|
+
writeFileSync(this.cacheFile, JSON.stringify({ hash: this.currentHash, cssCacheToken }), 'utf-8');
|
|
51
|
+
log('Mise à jour du fichier de cache');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=Cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../src/plugins/iconfont/Cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACtC,OAAO,EAAC,GAAG,EAAC,MAAM,a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,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,WAAW,IAAI,IAAI,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,cAAc;QACV,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACjC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,EAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAChG,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC3C,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/plugins/iconfont/Logger.ts"],"names":[],"mappings":"AAEA,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../src/plugins/iconfont/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,GAAG,CAAC,OAAe;IAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,2BAA2B,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitePluginIconfont.d.ts","sourceRoot":"","sources":["../../../src/plugins/iconfont/VitePluginIconfont.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAiB,MAAM,MAAM,CAAC;AACjD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CA0D/E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { globSync } from "glob";
|
|
2
|
+
import { BuildFont } from "./BuildFont.js";
|
|
3
|
+
import { Cache } from "./Cache.js";
|
|
4
|
+
import { log } from "./Logger.js";
|
|
5
|
+
export default function VitePluginIconfont(userOptions) {
|
|
6
|
+
const options = {
|
|
7
|
+
fontName: 'iconfont',
|
|
8
|
+
svgs: 'src/images/icons/**/*.svg',
|
|
9
|
+
...userOptions
|
|
10
|
+
};
|
|
11
|
+
const builder = new BuildFont(options);
|
|
12
|
+
let files = globSync(options.svgs);
|
|
13
|
+
let cacheService = null;
|
|
14
|
+
return {
|
|
15
|
+
name: 'assets-toolkit-iconfont',
|
|
16
|
+
configResolved(config) {
|
|
17
|
+
cacheService = new Cache(config.logger);
|
|
18
|
+
},
|
|
19
|
+
configureServer(server) {
|
|
20
|
+
const watcher = server.watcher;
|
|
21
|
+
watcher.on('change', async (path) => {
|
|
22
|
+
files = globSync(options.svgs);
|
|
23
|
+
const match = files.find(svg => path.endsWith(svg));
|
|
24
|
+
if (match) {
|
|
25
|
+
await builder.build();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
watcher.on('add', async (path) => {
|
|
29
|
+
files = globSync(options.svgs);
|
|
30
|
+
const match = files.find(svg => path.endsWith(svg));
|
|
31
|
+
if (match) {
|
|
32
|
+
await builder.build();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
watcher.on('unlink', async (path) => {
|
|
36
|
+
const match = files.find(svg => path.endsWith(svg));
|
|
37
|
+
if (match) {
|
|
38
|
+
await builder.build();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
async buildStart() {
|
|
43
|
+
if (!cacheService)
|
|
44
|
+
return;
|
|
45
|
+
let buildFont = true;
|
|
46
|
+
const currentHash = cacheService.getFilesHash(files);
|
|
47
|
+
cacheService.setCurrentHash(currentHash);
|
|
48
|
+
if (cacheService.getPreviousHash() === currentHash) {
|
|
49
|
+
log('Aucune modification détectée');
|
|
50
|
+
buildFont = false;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
cacheService.writeCacheFile();
|
|
54
|
+
}
|
|
55
|
+
return await builder.build({
|
|
56
|
+
cssCacheToken: cacheService.getPreviousCssCacheToken(),
|
|
57
|
+
buildFont
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=VitePluginIconfont.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitePluginIconfont.js","sourceRoot":"","sources":["../../../src/plugins/iconfont/VitePluginIconfont.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAIhC,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,WAA4B;IACnE,MAAM,OAAO,GAAG;QACZ,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,2BAA2B;QACjC,GAAG,WAAW;KACjB,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IACvC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,YAAY,GAAiB,IAAI,CAAC;IAEtC,OAAO;QACH,IAAI,EAAE,yBAAyB;QAC/B,cAAc,CAAC,MAAsB;YACjC,YAAY,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC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AC;YACrB,MAAM,WAAW,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAEzC,IAAG,YAAY,CAAC,eAAe,EAAE,KAAK,WAAW,EAAE,CAAC;gBAChD,GAAG,CAAC,8BAA8B,CAAC,CAAC;gBACpC,SAAS,GAAG,KAAK,CAAC;YACtB,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,cAAc,EAAE,CAAC;YAClC,CAAC;YACD,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC;gBACvB,aAAa,EAAE,YAAY,CAAC,wBAAwB,EAAE;gBACtD,SAAS;aACZ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
%icon-base-styles {
|
|
2
|
+
display: block;
|
|
3
|
+
vertical-align: middle;
|
|
4
|
+
font-family: "{{ fontName }}";
|
|
5
|
+
font-style: normal;
|
|
6
|
+
font-weight: normal;
|
|
7
|
+
font-variant: normal;
|
|
8
|
+
text-transform: none;
|
|
9
|
+
line-height: 1;
|
|
10
|
+
letter-spacing: normal;
|
|
11
|
+
word-wrap: normal;
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
direction: ltr;
|
|
14
|
+
text-decoration: inherit;
|
|
15
|
+
text-rendering: optimizeLegibility;
|
|
16
|
+
-moz-osx-font-smoothing: grayscale;
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
font-smoothing: antialiased;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
{% for glyph in glyphs %}
|
|
22
|
+
$iconfont-icon-{{glyph.name}}: "\{{ glyph.unicode }}";
|
|
23
|
+
{% endfor %}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use "iconfonts-vars";
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: "{{ fontName }}";
|
|
4
|
+
src: url('{{ fontPath ~ fontName }}.woff2{% if cacheToken %}?v={{ cacheToken }}&{% else %}?{% endif %}no-inline') format('woff2'),
|
|
5
|
+
url('{{ fontPath ~ fontName }}.woff{% if cacheToken %}?v={{ cacheToken }}&{% else %}?{% endif %}no-inline') format('woff');
|
|
6
|
+
font-weight: normal;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
font-display: block;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
{%- for glyph in glyphs %}
|
|
12
|
+
.{{ className }}-{{glyph.name}}:before{%- if loop.last == false -%}{{ ',' }}{%- endif -%}
|
|
13
|
+
{% endfor %} {
|
|
14
|
+
@extend %icon-base-styles;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
{%- for glyph in glyphs %}
|
|
18
|
+
.{{ className }}-{{glyph.name}}:before {
|
|
19
|
+
content: "\{{ glyph.unicode }}";
|
|
20
|
+
}
|
|
21
|
+
{%- endfor %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildSpriteFile.d.ts","sourceRoot":"","sources":["../../../src/plugins/svgstore/BuildSpriteFile.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAEpD;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqE5E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @ts-ignore — fs-extra est CJS
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
// @ts-ignore — svgstore n'a pas de types officiels
|
|
5
|
+
import svgstore from 'svgstore';
|
|
6
|
+
import { log } from "./Logger.js";
|
|
7
|
+
import { optimize } from "svgo";
|
|
8
|
+
import { glob } from "glob";
|
|
9
|
+
/**
|
|
10
|
+
* Génère un sprite SVG à partir d'un dossier d'icônes
|
|
11
|
+
*/
|
|
12
|
+
export async function generateSprite(options) {
|
|
13
|
+
const { srcDir = 'src/images/icons-sprite', targetFile = 'src/images/sprite.svg', symbolId = '[name]' } = options;
|
|
14
|
+
try {
|
|
15
|
+
const sprites = svgstore();
|
|
16
|
+
const iconsDir = path.resolve(process.cwd(), srcDir);
|
|
17
|
+
if (!await fs.pathExists(iconsDir)) {
|
|
18
|
+
log(`Le dossier source n'existe pas : ${iconsDir}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const files = (await glob(iconsDir + '/**/*.svg')).sort();
|
|
22
|
+
for (const file of files) {
|
|
23
|
+
if (path.extname(file) === '.svg') {
|
|
24
|
+
const id = symbolId.replace('[name]', path.parse(file).name);
|
|
25
|
+
const content = await fs.readFile(file, 'utf8');
|
|
26
|
+
sprites.add(id, content);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const result = optimize(sprites.toString(), {
|
|
30
|
+
plugins: [
|
|
31
|
+
'removeEmptyContainers',
|
|
32
|
+
'removeDoctype',
|
|
33
|
+
'removeXMLNS',
|
|
34
|
+
'removeDimensions',
|
|
35
|
+
'removeXMLProcInst',
|
|
36
|
+
'cleanupNumericValues',
|
|
37
|
+
'convertShapeToPath',
|
|
38
|
+
'collapseGroups',
|
|
39
|
+
{
|
|
40
|
+
name: 'removeAttrs',
|
|
41
|
+
params: {
|
|
42
|
+
attrs: [
|
|
43
|
+
'stroke',
|
|
44
|
+
'stroke-width',
|
|
45
|
+
'stroke-linecap',
|
|
46
|
+
'stroke-linejoin',
|
|
47
|
+
'stroke-miterlimit',
|
|
48
|
+
'style'
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{ name: 'convertColors', params: { currentColor: true } },
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
if ('error' in result && result.error) {
|
|
56
|
+
log(`Erreur SVGO : ${result.error}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const data = 'data' in result ? result.data : '';
|
|
60
|
+
const targetPath = path.resolve(process.cwd(), targetFile);
|
|
61
|
+
await fs.ensureDir(path.dirname(targetPath));
|
|
62
|
+
const existingContent = await fs.readFile(targetPath, 'utf-8').catch(() => '');
|
|
63
|
+
if (existingContent === data) {
|
|
64
|
+
log(`Sprite inchangé : ${targetFile}`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
await fs.writeFile(targetPath, data);
|
|
68
|
+
log(`Sprite généré avec succès : ${targetFile}`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
log(`Erreur lors de la génération du sprite : ${error}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=BuildSpriteFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildSpriteFile.js","sourceRoot":"","sources":["../../../src/plugins/svgstore/BuildSpriteFile.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,mDAAmD;AACnD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAG1B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAwB;IACzD,MAAM,EAAE,MAAM,GAAG,yBAAyB,EAAE,UAAU,GAAG,uBAAuB,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;IAElH,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;QAErD,IAAI,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,GAA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M,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAEjD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QAC3D,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAE7C,MAAM,eAAe,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/E,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YAC3B,GAAG,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;YACvC,OAAO;QACX,CAAC;QAED,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACrC,GAAG,CAAC,+BAA+B,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,GAAG,CAAC,4CAA4C,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/plugins/svgstore/Logger.ts"],"names":[],"mappings":"AAEA,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../src/plugins/svgstore/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,GAAG,CAAC,OAAe;IAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,2BAA2B,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitePluginSvgstore.d.ts","sourceRoot":"","sources":["../../../src/plugins/svgstore/VitePluginSvgstore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAsC/E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { globSync } from "glob";
|
|
2
|
+
import { generateSprite } from "./BuildSpriteFile.js";
|
|
3
|
+
import { log } from "./Logger.js";
|
|
4
|
+
export default function VitePluginSvgstore(userOptions) {
|
|
5
|
+
const options = {
|
|
6
|
+
srcDir: 'src/images/icons-sprite',
|
|
7
|
+
targetFile: 'src/images/sprite.svg',
|
|
8
|
+
symbolId: '[name]',
|
|
9
|
+
...userOptions
|
|
10
|
+
};
|
|
11
|
+
let files = globSync(options.srcDir + '/**/*.svg');
|
|
12
|
+
return {
|
|
13
|
+
name: 'assets-toolkit-svgstore',
|
|
14
|
+
configureServer(server) {
|
|
15
|
+
const watcher = server.watcher;
|
|
16
|
+
const handleChange = async (path) => {
|
|
17
|
+
files = globSync(options.srcDir + '/**/*.svg');
|
|
18
|
+
const match = files.find(svg => path.endsWith(svg));
|
|
19
|
+
if (match) {
|
|
20
|
+
await generateSprite(options);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
watcher.on('change', handleChange);
|
|
24
|
+
watcher.on('add', handleChange);
|
|
25
|
+
watcher.on('unlink', async (path) => {
|
|
26
|
+
const match = files.find(svg => path.endsWith(svg));
|
|
27
|
+
if (match) {
|
|
28
|
+
files = globSync(options.srcDir + '/**/*.svg');
|
|
29
|
+
await generateSprite(options);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
async buildStart() {
|
|
34
|
+
log('Génération du sprite SVG');
|
|
35
|
+
await generateSprite(options);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=VitePluginSvgstore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitePluginSvgstore.js","sourceRoot":"","sources":["../../../src/plugins/svgstore/VitePluginSvgstore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAIhC,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,WAA4B;IACnE,MAAM,OAAO,GAAoB;QAC7B,MAAM,EAAE,yBAAyB;QACjC,UAAU,EAAE,uBAAuB;QACnC,QAAQ,EAAE,QAAQ;QAClB,GAAG,WAAW;KACjB,CAAC;IAEF,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;IAEnD,OAAO;QACH,IAAI,EAAE,yBAAyB;QAC/B,eAAe,CAAC,MAAM;YAClB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;YAE/B,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;gBACxC,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;gBAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpD,IAAI,KAAK,EAAE,CAAC;oBACR,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC;YACL,CAAC,CAAC;YAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAChC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAY,EAAE,EAAE;gBACxC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpD,IAAI,KAAK,EAAE,CAAC;oBACR,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;oBAC/C,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QACD,KAAK,CAAC,UAAU;YACZ,GAAG,CAAC,0BAA0B,CAAC,CAAC;YAChC,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ServerOptions } from "node:https";
|
|
2
|
+
export interface LocalConfig {
|
|
3
|
+
/** Configuration du serveur de dev (certificats HTTPS) */
|
|
4
|
+
server?: {
|
|
5
|
+
https?: ServerOptions;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface IconfontOptions {
|
|
9
|
+
/** Glob pattern des fichiers SVG sources */
|
|
10
|
+
svgs?: string;
|
|
11
|
+
/** Nom de la font générée */
|
|
12
|
+
fontName?: string;
|
|
13
|
+
/** Dossier de sortie des fichiers SCSS */
|
|
14
|
+
scssDir?: string;
|
|
15
|
+
/** Nom de la classe CSS de base des icônes */
|
|
16
|
+
iconClassName?: string;
|
|
17
|
+
/** Chemin relatif vers la font dans le CSS */
|
|
18
|
+
fontPath?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SvgstoreOptions {
|
|
21
|
+
/** Dossier source des SVG du sprite */
|
|
22
|
+
srcDir?: string;
|
|
23
|
+
/** Fichier de sortie du sprite */
|
|
24
|
+
targetFile?: string;
|
|
25
|
+
/** Pattern pour l'id des symboles ([name] sera remplacé) */
|
|
26
|
+
symbolId?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CreateViteConfigOptions {
|
|
29
|
+
/** Chemin de base pour le serveur de dev (ex. "/themes/custom/mon-theme/assets") */
|
|
30
|
+
base: string;
|
|
31
|
+
/** Configuration locale (certificats HTTPS), typiquement chargée depuis config.json (non versionné) */
|
|
32
|
+
localConfig?: LocalConfig;
|
|
33
|
+
/** Options du plugin iconfont (false pour désactiver) */
|
|
34
|
+
iconfont?: IconfontOptions | false;
|
|
35
|
+
/** Glob patterns pour les fichiers d'entrée */
|
|
36
|
+
entries?: string[];
|
|
37
|
+
/** Patterns à ignorer */
|
|
38
|
+
entriesIgnore?: string[];
|
|
39
|
+
/** Options du plugin svgstore (false pour désactiver) */
|
|
40
|
+
svgstore?: SvgstoreOptions | false;
|
|
41
|
+
/** Activer le plugin imagemin (nécessite vite-plugin-imagemin en peerDep) */
|
|
42
|
+
imagemin?: boolean;
|
|
43
|
+
/** Glob patterns pour le live reload (false pour désactiver, nécessite vite-plugin-live-reload en peerDep) */
|
|
44
|
+
liveReload?: string[] | false;
|
|
45
|
+
/** Définition des manual chunks (id => nom du chunk) */
|
|
46
|
+
manualChunks?: (id: string) => string | undefined;
|
|
47
|
+
/** Plugins Vite supplémentaires */
|
|
48
|
+
plugins?: any[];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,WAAW;IACxB,0DAA0D;IAC1D,MAAM,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,aAAa,CAAC;KACzB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types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@absolu/assets-toolkit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Toolkit Vite pour les pipelines d'assets front-end : factory de configuration, plugins iconfont et svgstore",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc && cp -r src/plugins/iconfont/templates dist/plugins/iconfont/",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"chalk": "^5.6.2",
|
|
23
|
+
"glob": "^10.4.5",
|
|
24
|
+
"nunjucks": "^3.2.4",
|
|
25
|
+
"svg2ttf": "^6.0.3",
|
|
26
|
+
"svgicons2svgfont": "^13.0.0",
|
|
27
|
+
"svgo": "^4.0.1",
|
|
28
|
+
"svgstore": "^3.0.1",
|
|
29
|
+
"ttf2woff": "^3.0.0",
|
|
30
|
+
"ttf2woff2": "^7.0.0",
|
|
31
|
+
"fs-extra": "^11.2.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/fs-extra": "^11.0.4",
|
|
35
|
+
"@types/node": "^20.11.0",
|
|
36
|
+
"@types/nunjucks": "^3.2.6",
|
|
37
|
+
"@types/svg2ttf": "^5.0.3",
|
|
38
|
+
"@types/ttf2woff": "^2.0.4",
|
|
39
|
+
"typescript": "^5.3.3",
|
|
40
|
+
"vite": "^6.4.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"vite": ">=5.0.0",
|
|
44
|
+
"sass": ">=1.0.0",
|
|
45
|
+
"vite-plugin-imagemin": ">=0.6.0",
|
|
46
|
+
"vite-plugin-live-reload": ">=3.0.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"vite-plugin-imagemin": { "optional": true },
|
|
50
|
+
"vite-plugin-live-reload": { "optional": true }
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT"
|
|
53
|
+
}
|