File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed
Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -30,5 +30,5 @@ __DATE__
3030
3131* 🔒 [ Security]
3232
33-
33+ - Build : transformation images en base 64 pour se passer de lodash.template ( # 488 )
3434---
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const path = require("path");
44var yargs = require ( "yargs" ) ;
55const child_process = require ( "child_process" ) ;
66const fg = require ( "fast-glob" ) ;
7- const base64Img = require ( "base64-img" ) ;
7+
88
99async function main ( ) {
1010 const argv = yargs
@@ -73,7 +73,21 @@ async function main () {
7373 if ( ! url . startsWith ( "data:" ) ) {
7474 url = path . normalize ( url ) ;
7575 url = path . join ( path . dirname ( entry ) , url ) ;
76- const data = base64Img . base64Sync ( url ) ;
76+ // Remplacement de base64-img par une lecture/encodage natif
77+ const imgBuffer = fse . readFileSync ( url ) ;
78+ const mimeType = ( ( ) => {
79+ const ext = path . extname ( url ) . toLowerCase ( ) ;
80+ switch ( ext ) {
81+ case '.png' : return 'image/png' ;
82+ case '.jpg' :
83+ case '.jpeg' : return 'image/jpeg' ;
84+ case '.svg' : return 'image/svg+xml' ;
85+ case '.gif' : return 'image/gif' ;
86+ case '.webp' : return 'image/webp' ;
87+ default : return 'application/octet-stream' ;
88+ }
89+ } ) ( ) ;
90+ const data = `data:${ mimeType } ;base64,${ imgBuffer . toString ( 'base64' ) } ` ;
7791 line = line . substring ( 0 , start ) + "('" + data + "'" + line . substring ( end ) ;
7892 }
7993 }
Original file line number Diff line number Diff line change 11{
22 "name" : " geopf-extensions-openlayers" ,
33 "description" : " French Geoportal Extensions for OpenLayers libraries" ,
4- "version" : " 1.0.0-beta.8-491 " ,
5- "date" : " 25/02 /2026" ,
4+ "version" : " 1.0.0-beta.8-488 " ,
5+ "date" : " 04/03 /2026" ,
66 "module" : " src/index.js" ,
77 "directories" : {},
88 "engines" : {
6969 "@babel/preset-env" : " ^7.23.9" ,
7070 "@types/sanitize-html" : " ^2.16.0" ,
7171 "babel-loader" : " ^9.1.3" ,
72- "base64-img" : " ^1.0.4" ,
7372 "copy-webpack-plugin" : " ^12.0.2" ,
7473 "core-js" : " ^3.35.1" ,
7574 "css-loader" : " ^7.0.0" ,
You can’t perform that action at this time.
0 commit comments