question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blank page - bundle not executed.

See original GitHub issue
  • Operating System: MacOS 10.13.4
  • Node Version: 8.11.3
  • NPM Version: 6.2
  • webpack Version: 4.12.2
  • webpack-cli: 3.0.8
  • webpack-dev-server Version: 3.1.14
  • This is a bug
  • This is a modification request

Code

webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
	context: path.resolve(__dirname, '../src'),
	entry: './index.tsx',
	output: {
		filename: '[name].bundle.js',
		path: path.resolve(__dirname, '../dist'),
	},
	devServer: {
		hot: true,
		open: true,
		port: 9000,
		inline: true,
	},
	devtool: 'source-map',
	resolve: {
		extensions: ['.ts', '.tsx', '.js', 'jsx'],
	},
	module: {
		rules: [
			{
				test: /\.(tsx|ts)$/,
				exclude: /node_modules/,
				loader: 'ts-loader',
			}
		]
	},
	plugins: [
		new HtmlWebpackPlugin()
	]
}

index.tsx

console.log('test')

package.json

"start": "webpack-dev-server --config ./webpack/webpack.config.js"

Expected Behavior

Serve blank application that logs ‘test’ in console. I’d like to display react application, but it seems website served by webpack-dev-server never executes bundle code.

Actual Behavior

Blank page, no log. If I add publicPath to output webpack-dev-server displays only already bundled content from dist, no HMR. Application works if bundled with webpack and run manually. I tried few configuration with contentBase and watchContentBasebut always:

  • if there is HMR log in console there is no bundle code executed
  • if there is no HMR log webpack-dev-server doesn’t bundle anything only serves already builded static files

For Bugs; How can we reproduce the behavior?

Webpack configuration.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

45reactions
brandonwiemanncommented, Nov 1, 2018

I was having this exact same issue and realized that I was using optimization.splitChunks in my default webpack config but wasn’t linking to the common (chunked) script on my entry page. Hopefully this helps someone else.

9reactions
golearycommented, Jun 5, 2020

This issue for me was a result of the template for HtmlWebpackPlugin having the same path/name as the generated index.html. On file changes the the bundles were rebuilt but the original template file was served (with no script tags) instead of the generated file.

The fix was a simple changing of the template filename & updating the name in the HtmlWebpackPlugin plugin config to this new name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh page on react-router outputs blank page, bundle.js is ...
I checked the console after the page is refreshed, and there is no bundle.js loaded, only index.html is loaded - which explains the...
Read more >
Blank page when Webpack React deploys - No bundle.js in ...
I'm trying to deploy a basic application with React and Webpack, but only a blank page is displayed. I can see in the...
Read more >
Learn Build Tools: Rock, Paper, Bundle Project extra ...
Basically, I completed the entire project but it would not open properly in the browser when I ran 'npm run start'
Read more >
Troubleshooting Session Manager - AWS Documentation
Managed node not available or not configured for Session Manager ... Problem: You start a session and Session Manager displays a blank screen....
Read more >
When using react.js webpack-dev-server does not bundle
When you run the app, there is an embedded web server that runs our project, when we edit a file like App.js, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found