Allow nodejs build process to use a lower RAM value
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
cdca2d24e4
commit
d5c90af809
@ -77,9 +77,9 @@ yarn install
|
|||||||
Finally, we can build the front-end (this can take a few seconds).
|
Finally, we can build the front-end (this can take a few seconds).
|
||||||
|
|
||||||
!!! warning
|
!!! warning
|
||||||
Building front-end can consume up to 512MB of RAM by default. If it's too much or not sufficient for your setup, you can adjust the maximum memory used by prefixing the command with the following option:
|
Building front-end can consume up to 2048MB of RAM by default. If it's too much or not sufficient for your setup, you can adjust the maximum memory used by prefixing the command with the following option:
|
||||||
```
|
```
|
||||||
NODE_OPTIONS=--max_old_space_size=4096
|
NODE_BUILD_MEMORY=1024
|
||||||
```
|
```
|
||||||
```bash
|
```bash
|
||||||
yarn run build
|
yarn run build
|
||||||
|
@ -50,6 +50,11 @@ yarn install
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Rebuild Mobilizon's front-end
|
### Rebuild Mobilizon's front-end
|
||||||
|
!!! warning
|
||||||
|
Building front-end can consume up to 2048MB of RAM by default. If it's too much or not sufficient for your setup, you can adjust the maximum memory used by prefixing the command with the following option:
|
||||||
|
```
|
||||||
|
NODE_BUILD_MEMORY=1024
|
||||||
|
```
|
||||||
```bash
|
```bash
|
||||||
yarn run build
|
yarn run build
|
||||||
cd ../
|
cd ../
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
runtimeCompiler: true,
|
runtimeCompiler: true,
|
||||||
lintOnSave: true,
|
lintOnSave: true,
|
||||||
filenameHashing: true,
|
filenameHashing: true,
|
||||||
outputDir: path.resolve(__dirname, "../priv/static"),
|
outputDir: path.resolve(__dirname, "../priv/static"),
|
||||||
|
configureWebpack: (config) => {
|
||||||
|
// Limit the used memory when building
|
||||||
|
// Source : https://stackoverflow.com/a/55810460/10204399
|
||||||
|
// get a reference to the existing ForkTsCheckerWebpackPlugin
|
||||||
|
const existingForkTsChecker = config.plugins.filter(
|
||||||
|
(p) => p instanceof ForkTsCheckerWebpackPlugin
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
// remove the existing ForkTsCheckerWebpackPlugin
|
||||||
|
// so that we can replace it with our modified version
|
||||||
|
config.plugins = config.plugins.filter((p) => !(p instanceof ForkTsCheckerWebpackPlugin));
|
||||||
|
|
||||||
|
// copy the options from the original ForkTsCheckerWebpackPlugin
|
||||||
|
// instance and add the memoryLimit property
|
||||||
|
const forkTsCheckerOptions = existingForkTsChecker.options;
|
||||||
|
forkTsCheckerOptions.memoryLimit = process.env.NODE_BUILD_MEMORY || 2048;
|
||||||
|
|
||||||
|
config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions));
|
||||||
|
},
|
||||||
// configureWebpack: {
|
// configureWebpack: {
|
||||||
// optimization: {
|
// optimization: {
|
||||||
// splitChunks: {
|
// splitChunks: {
|
||||||
|
Loading…
Reference in New Issue
Block a user