2

I was building a nodejs app (typescript, react, webpack) and the build was working fine. I.e. I got in the output what I expected. A HTML file, with the bundle file I expected.

Suddenly, without any change in my code, webpack is only generating a the bundle javascript file (as usual) but the HTML file is gone, i.e it does not generate any more. Here my webpack config file:

const path = require('path'); const config = { mode: "production", entry: path.resolve(__dirname, "../src/index.tsx"), resolve: { extensions: ['.tsx', '.js'] }, output: { // options related to how webpack emits results path: path.resolve(__dirname, "../dist"), filename: "bundle.js" }, module: { rules: [ { test: /.tsx$|.js$/, loader: "ts-loader" , include: path.resolve(__dirname, "../src") }, ] } } module.exports = config; 

Any clue why my HTML file is not generated anymore and how I can recover it? Thank you!

4
  • Webpack config is fine. Give us at least any way to reproduce your problem. Commented Aug 7, 2018 at 17:53
  • What if you add a filename property in your output ? Like this `filename: "<output-file>.js". Commented Aug 7, 2018 at 18:18
  • @rach8garg no difference. Still no HTML file generated. Commented Aug 9, 2018 at 15:41
  • what is your webpack version ? Commented Aug 10, 2018 at 7:08

2 Answers 2

1

As I know Webpack by default outputs main.js if you do not specify output filename configuration like this code. Try this code:

const path = require('path'); const config = { entry: path.resolve(__dirname, "../src/index.tsx"), resolve: { extensions: ['.tsx', '.js'] }, output: { // options related to how webpack emits results path: path.resolve(__dirname, "../dist"), filename: 'my-first-webpack.bundle.js' }, module: { rules: [ { test: /\.tsx$/, loader: "ts-loader" , include: path.resolve(__dirname, "../src") }, ] } } module.exports = config; 
Sign up to request clarification or add additional context in comments.

3 Comments

I mean, the problem is where is the HTML !? i.e. .html file
Hi Jose, did you specify output file name in your webpack config file ?
@Sedar yes it is specified.
0

So the HTML was actually never created. So the question is obsolete.

I was confused because before there used to be an HTML in the output. But it was not generated by webpack (it came from Typescript script)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.