I am getting a "JavaScript heap out of memory" error when running a build with crawl: true. Here is the console output
<--- Last few GCs --->
[88328:0x103800000] 371328 ms: Mark-sweep 1402.1 (2063.0) -> 1402.0 (2052.5) MB, 125.9 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 127 ms) last resort
[88328:0x103800000] 371463 ms: Mark-sweep 1402.0 (2052.5) -> 1401.8 (2052.0) MB, 134.4 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1c73bc09bbd9 <JS Object>
1: /* anonymous */ [.../node_modules/static-site-generator-webpack-plugin/index.js:88] [pc=0x502f8d5fb66](this=0x2690e5c8a1e1 <JS Global Object>,key=0xf0700a8dc39 <Very long string[45664]>)
2: arguments adaptor frame: 3->1
3: map [native array.js:~832] [pc=0x502f91c16c7](this=0x395e0fd11431 <JS Array[1]>,bd=0x395e0fd11451 <JS Function (SharedFunctionI...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/Users/xxx/.nvm/versions/node/v8.2.1/bin/node]
...
If I disable crawl mode, the build works, but obviously I don't get all my static pages generated.
Node 8.2.1
webpack 2.6.1
static-site-generator-webpack-plugin 3.4.1
The app works normally when I build it as a purely client app using webpack-dev-server.
Is there any way to debug why this is causing the memory error?
This is my full Webpack config
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
let plugins = [
new ExtractTextPlugin('style.css'),
new StaticSiteGeneratorPlugin({
crawl: true,
paths: ['/']
}),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, 'src', 'favicon.ico'),
to: path.resolve(__dirname, 'dist')
},
{
from: path.resolve(__dirname, 'fonts'),
to: path.resolve(__dirname, 'dist', 'fonts')
}
]),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin()
];
if (process.env.ANALYZE_WEBPACK) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
plugins.push(
new BundleAnalyzerPlugin({
openAnalyzer: false
})
);
}
module.exports = {
entry: {
bundle: path.resolve(__dirname, 'src')
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd'
},
plugins: plugins,
// exclude
externals: {
'babel-standalone': 'babel-standalone'
},
module: {
rules: [
{
test: /\.js$/,
include: [path.resolve(__dirname, 'src')],
use: {
loader: 'babel-loader',
options: {
presets: ['react', 'es2015']
}
}
},
{
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
camelCase: true,
localIdentName: '[name]__[local]--[hash:base64:5]'
}
},
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')]
}
},
{
loader: 'sass-loader'
}
]
})
}
]
}
};
I am getting a "JavaScript heap out of memory" error when running a build with
crawl: true. Here is the console outputIf I disable crawl mode, the build works, but obviously I don't get all my static pages generated.
Node 8.2.1
webpack 2.6.1
static-site-generator-webpack-plugin 3.4.1
The app works normally when I build it as a purely client app using webpack-dev-server.
Is there any way to debug why this is causing the memory error?
This is my full Webpack config