mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-12 15:22:54 +01:00
Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const fs = require('fs');
|
||||
const packageJson = require('../../package');
|
||||
|
||||
module.exports = function ({ production }) {
|
||||
//some modules are not packaged in the production build to reduce app size
|
||||
//make sure webpack bundles those and don't exclude them
|
||||
//skip this in dev mode since it slows down the bundling
|
||||
function getExcludedNodeModules() {
|
||||
return packageJson.build.files
|
||||
.map((pattern) => pattern.match(/\!node_modules\/(.+)/))
|
||||
.filter((match) => match !== null)
|
||||
.map((match) => match[1]);
|
||||
}
|
||||
|
||||
// don't bundle external modules from node_modules
|
||||
let externals = [];
|
||||
|
||||
if (fs.existsSync('node_modules')) {
|
||||
externals = [...externals, ...fs.readdirSync('node_modules')];
|
||||
}
|
||||
|
||||
// When building normally in a monorepo
|
||||
if (fs.existsSync('../../node_modules')) {
|
||||
externals = [...externals, ...fs.readdirSync('../../node_modules')];
|
||||
}
|
||||
|
||||
if (production) {
|
||||
// ..except these
|
||||
getExcludedNodeModules().forEach((m) => {
|
||||
const i = externals.indexOf(m);
|
||||
if (i !== -1) externals.splice(i, 1);
|
||||
});
|
||||
}
|
||||
|
||||
return externals;
|
||||
};
|
||||
Reference in New Issue
Block a user