简体   繁体   中英

Webpack dev server not working (strange page loaded)

I work with web pack and when I try to run the run script (npm run build:dev) i get this weird page with is actually my workspace folders instead the actual website: 在此处输入图像描述

heres my package.json if needed and I used VSCode:

{ "name": "pro-lyrics", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "webpack", "start:dev": "webpack serve", "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "webpack": "^5.12.3", "webpack-cli": "^4.3.1", "webpack-dev-server": "^3.11.1" } }

You need to define where you keep your HTML files in your configuration file for webpack

  devServer: {  
    contentBase: './' // this is default main folder
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM