M
M
mrSeller2019-05-18 14:06:05
webpack
mrSeller, 2019-05-18 14:06:05

Webpack doesn't include js file in dev development - why?

Set up a build with webpack-server:

webpack.config.js
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: './src/main.js',
  output: {
    filename: 'app.js',
    path: path.resolve(__dirname, './public'),
    publicPath: '/public/'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: '/node_modules/'
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      hash: true,
      template: './src/index.html',
      filename: './index.html'
    })
  ],
  devServer: {
    contentBase: './src',
    overlay: true,
    historyApiFallback: true
  }
}


When running the webpack-server, the js file is not embedded in index.html, but when the production build is built, everything is embedded as it should.
What didn't I learn?
I’m setting it up not for the first time and it always worked, but here I’m breaking my head for an hour.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question