Giter Site home page Giter Site logo

Comments (2)

MaoShizhong avatar MaoShizhong commented on September 2, 2024

This wouldn't be a bug. From the sounds of it, your watch npm script runs webpack --watch, i.e. upon every change to the dependency graph or other files in the bundle, re-run the bundling. When that happens, the clean: true option under output will clear your dist directory before it outputs the resulting bundle into it.

This doesn't have anything to do with webpack-dev-server. If you're using the dev server, you won't need to also run webpack --watch. The dev server is standalone, then once you're ready to bundle and deploy, you bundle then deploy dist.

If you want to use webpack's watch mode, then you won't use webpack-dev-server.

What's happening is that because you haven't set a template for HtmlWebpackPlugin, it's going to delete everything in dist (including any changes you made to dist/index.html) before it bundles. What you're supposed to do as per the lessons and Restaurant Page project, is have an HTML file in src, then set that as the template for HtmlWebpackPlugin. You don't do any development work in dist at all - that's reserved purely for what Webpack outputs when you bundle things.

If you're still having problems with understanding any part of the Webpack lessons, feel most free to pop in our community Discord and write up a detailed and specific question, and I'm sure someone will be able to help you with whatever issue you're running into!

from curriculum.

dawrentz avatar dawrentz commented on September 2, 2024

from curriculum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.