0

Here is a repo I just created to get this issue solved: https://github.com/DevCubeHD/WebpackStaticPage

First of all: File structure. There are two important folders you should know to understand my example in case it isn't even convention. The /src folder is where all the raw content goes and the /dist folder is where the packed website goes by default. From there it is ready to deploy on any server. I'm not sure if development needs this directory anyways, but I hope you are.

I'm trying to set-up two webpack scripts for production and development. Production works fine: The script runs trough and the page is put into /dist.

In development I want to use webkit hotloader to instantly apply changes to the page just when I made some. It does run and the output seems very good, but when it comes to the page it stucks on [WDS] App hot update... and does not update the content. Even after a refresh of the page the content is still the old. The only thing that helps is running the production script.

To run the development script use yarn start or npm run start. For a fresh /dist directory you can use the production script yarn build or npm run build at the moment.

Please help me to fix the webback-dev-server so I can develop efficently. :) Thanks alot!

Felix Gaebler
  • 702
  • 4
  • 23

2 Answers2

0

You should use HotModuleReplacementPlugin from webpack.

plugins: [
    new webpack.HotModuleReplacementPlugin()
]

Hot Module Replacement Plugin Link

0

I am able to achieve this by doing the following things,

  1. Remove main.js and main.less from webpack entry points and only have index.html
  2. Add HotModuleReplacementPlugin
  3. Remove assets folder and putting all files in a single folder.
Afaq Ahmed Khan
  • 2,164
  • 2
  • 29
  • 39