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.