Skip to content

Commit

Permalink
fixed brfs pdfkit
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Dec 22, 2024
1 parent a7ff602 commit 7f5cde2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var path = require('path');
var fs = require('fs');
var TerserPlugin = require('terser-webpack-plugin');
var StringReplacePlugin = require("string-replace-webpack-plugin");
var webpack = require('webpack');
Expand Down Expand Up @@ -82,6 +83,24 @@ module.exports = {
})
}
},
// transpile to inline only required file
{
enforce: 'pre',
test: /pdfkit[/\\]js[/\\]/,
use: {
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: "fs.readFileSync(`${__dirname}/data/sRGB_IEC61966_2_1.icc`)",
replacement: function () {
const data = fs.readFileSync('node_modules/pdfkit/js/data/sRGB_IEC61966_2_1.icc');
return `Buffer("` + data.toString('base64') + `","base64");`;
}
}
]
})
}
},
{
enforce: "pre",
test: /\.(cjs|js)$/,
Expand Down Expand Up @@ -137,14 +156,6 @@ module.exports = {
})
}
},

{
enforce: 'post',
test: /pdfkit[/\\]js[/\\]pdfkit.es.js$/,
use: {
loader: "transform-loader?brfs"
}
},
{
enforce: 'post',
test: /fontkit[/\\]index.js$/,
Expand Down

0 comments on commit 7f5cde2

Please sign in to comment.