Closed
Description
Description
On large projects when recompiling using webpack-dev-server, html-webpack-plugin causes an out-of-memory (Invalid string length) error when calling compilation.getStats().toJson()
.
Error Message & Stack Trace
RangeError: Invalid string length
at formatError (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\webpack\lib\Stats.js:221:30)
at Array.map (<anonymous>)
at Stats.toJson (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\webpack\lib\Stats.js:229:56)
at Compiler.<anonymous> (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\html-webpack-plugin\index.js:68:44)
at Compiler.applyPluginsAsyncSeries (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\tapable\lib\Tapable.js:206:13)
at Compiler.emitAssets (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\webpack\lib\Compiler.js:354:8)
at onCompiled (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\webpack\lib\Compiler.js:58:19)
at applyPluginsAsync.err (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\webpack\lib\Compiler.js:510:14)
at next (C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\tapable\lib\Tapable.js:202:11)
at C:\TA30\workspace\Production\ECMAWF\ecm-awf-frontend\ecm-awf-frontend-html\node_modules\awesome-typescript-loader\src\instance.ts:501:25
at <anonymous>
Config
module.exports = {
context: __dirname + '/app',
entry: {
'app': './index'
},
output: {
path: __dirname + '/dist',
filename: '[name]-[hash].js'
},
resolve: {
extensions: ['.js', '.ts'],
modules: ['node_modules']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.scss$/,
use: [
'style-loader',
{loader: 'css-loader', options: {sourceMap: true}},
{loader: 'postcss-loader', options: {sourceMap: true}},
'resolve-url-loader',
{loader: 'sass-loader', options: {sourceMap: true}}
]
}
]
},
node: {
__filename: true
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
template: './index.ejs'
}),
new HardSourceWebpackPlugin()
],
devtool: 'cheap-module-eval-source-map'
devServer: {
contentBase: './dist',
historyApiFallback: true,
host: 'localhost',
port: 9000,
stats: {
assets: false,
chunks: false,
modules: false
}
}
};
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width">
<% for (var css in htmlWebpackPlugin.files.css) { %>
<link href="<%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
<% } %>
</head>
<body>
<awf-app></awf-app>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
</body>
</html>
Relevant Links
Possibly related issues:
webpack/webpack#6083
webpack/webpack#6501
webpack/webpack#5992
webpack/webpack#5120
webpack/webpack#6068
Environment
Node.js v8.7.0
Windows 7 x64
npm 5.6.0
webpack: 3.10.0
webpack-dev-server: 2.11.1
html-webpack-plugin: 2.30.1
Metadata
Metadata
Assignees
Labels
No labels