Questions about webpack compiled files

I created a new index.html as follows:

<html>
<head>
  <meta charset="utf-8">
</head>
<body>
  <script src="bundle.js"></script>
</body>
</html>

at the same time, a new entry.js entry file is created as follows:

document.write("hello world.")

then execute $webpack entry.js bundle.js

clipboard.png

seems to have succeeded!

but I found that there was nothing in bundle.js and nothing in the browser. Instead, a dist folder was generated with a mian.js
I modified index.html:

.
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
  <script src="dist/main.js"></script>
</body>
</html>

now the browser displays hello world

question:
Why didn"t you package the entry.js code into bundle.js as I expected?

May.22,2021

you can configure it yourself:

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

module.exports = {
    devtool: 'eval-source-map',
    entry: './entry.js',
    // -----------------------  -----------------------
    output: {
        path: './dist',
        filename: 'bundle.min.js',
    },
    devServer: {
        port: 8000,
        inline: true,
        contentBase: './src'
    },
    module: {
        loaders: [
            {
                test: /\.less$/,
                loader: 'style!css!less'
            },
            {
                test: /\.js$/,
                loader: 'babel',
                exclude: /node_modules/
            },
            {
                test: /\.(jpg|png|svg)$/,
                loader: 'url'
            }
        ]
    },
    plugins: [
        new htmlWebpackPlugin({
            template: './src/index.html'
        })
    ]
};

$ webpack entry.js bundle.js

this sentence means that the entry file entry is compiled into bundle, and referenced to index.html to perform the specific compilation process of
. You need to see the configuration information of your webpage
. If it is convenient for you, submit your webpage.config.js code

.

clipboard.png
the above information tells you that the output file cannot be found. It should be output to you according to the default main.js

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea3b72-1c78.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea3b72-1c78.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?