3

I just started with webpack, and I want to automatically generate index.html file using html-webpack-plugin.

My webpack.config.js:

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

module.exports = {
    plugins: [
        new HtmlWebpackPlugin({
            hash: true
        })
    ]
}

enter image description here

I execute "npm run dev" equals to webpack --mode development, and only 1 file generated "main.js".

I don't see any html files, could you please help me?

webpack: 4.5.0 html-webpack-plugin: 3.2.0

Thanks in advance

2 Answers 2

1

Try using the entry

entry: {
  main: [
    './src/'
  ]
},
Sign up to request clarification or add additional context in comments.

Comments

1

I found the issue

You just need to specify path in output, because HtmlWebpackPlugin is looking for path

output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].js'
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.