Skip to content

Commit

Permalink
Génère la liste des modules à exclure du build ui depuis les peerDeps…
Browse files Browse the repository at this point in the history
… du package
  • Loading branch information
marc-rutkowski committed Mar 5, 2024
1 parent 118f19b commit d714e43
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@ const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

function getPeerDependencies() {
try {
const pkg = require(path.resolve(process.cwd(), 'package.json'));
return Object.keys(pkg.peerDependencies);
} catch (err) {
return [];
}
}

/** Configuration Webpack */
module.exports = function (env, argv) {
// génère la liste des modules à exclure du build depuis les peerDeps du package
const externals = Object.fromEntries(getPeerDependencies().map(d => [d, d]));

return {
// configuration en fonction de l'environnement cible
mode: env.production ? 'production' : 'development',
Expand Down Expand Up @@ -41,12 +53,7 @@ module.exports = function (env, argv) {
},

// exclut du bundle les bibliothèques externes
externals: {
react: 'react',
'react-dom': 'react-dom',
classnames: 'classnames',
'@floating-ui/react': '@floating-ui/react',
},
externals,

// configuration de la génération
output: {
Expand Down

0 comments on commit d714e43

Please sign in to comment.