12/28/2022 0 Comments How to run webpack in production![]() ![]() Others will install the project as a package, and require the pre-built files in their project. This scenario is also used if we are creating library packages, instead servers. The webpack and webpack app dependencies can be placed in devDependencies. This means our project will need to ship with our build folder. This scenario is if we do not need to run webpack in production and we only serve the pre-built files in a node server. ![]() Scenario 2: If our project does not need to run webpack in the production environment, and has a pre-built copy to serve (or require by other projects): Assuming statement above to be reasonable, dependencies are the requirements to build this project and devDependencies will have things that are not related to building, such as unit testing. In this scenario, our project is no longer considered the "front end app", but instead "the project that builds the front end app". We now also call our project a "build server". For webpack (and many react) projects, we are actually using webpack as a build tool, which translates to our project being considered a "source project" waiting to be built. As says, node is historically used as a "server", but this is actually still be considered true. Packages required to build the webpack project are under dependencies, rather than devDependencies. Scenario 1: If your project needs to run webpack in the production environment before serving: More commonly I see people start with putting everything in dependencies but should lean towards devDependencies, and figure out how to use it properly. The argument to put most dependencies under dependencies instead of devDependencies can actually go both ways. ![]() Webpack projects seem to add a layer of confusion, but we are simply not asking ourselves the right questions: "How will this project be used in production?", and "Will we run webpack during production?" ![]() This conversation states why it works, but leaves one unsure of the reasoning behind it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |