• Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

87
Views
(node js) webpack-dev-server is not compiling correctly

I have a simple webpack, webpack-cli and webpack-dev-server project in Node going. My JS gets compiled from src/ to dist/js/ just fine when using npx webpack, but something weird is going on when I use npx webpack serve: I get the usual webpack 5.64.0 compiled successfully in 89 ms messages when I make changes to the javascript in the src/ folder, and the live server reloads, but no changes are actually made to the dist 'main.js' file. Not even with a hard refresh or a dev server restart. Here is my package.json...

{
  "name": "fate-clone",
  "version": "1.0.0",
  "scripts": {
    "start": "webpack serve --mode=development",
    "build": "webpack"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pixi.js": "^6.2.0", //Just a WebGL graphics engine
    "webpack": "^5.64.0"
  },
  "devDependencies": {
    "webpack-cli": "^4.9.1",
    "webpack-dev-server": "^4.5.0"
  }
}

And my webpack.config.js...

const path = require('path')

module.exports = {
  stats: 'minimal',
  entry: path.join(__dirname, "src/index.js"),
  watch: true,
  output: {
    filename: 'main.js',
    path: path.join(__dirname, 'dist/js'),
  },
  devServer: {
    hot: true,
    compress: true,
    static:  {
      directory: path.join(__dirname, 'dist'),
    },
    port: 8080,
  }
}

Again, having 'npx webpack' running with watch=true compiles everything perfectly, so I'm confused what I'm missing that's causing webpack-dev-server to be compiling some mystery main.js file.

9 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.