I have been studying webpack4, recently. To be honest, I am being tortured crazy and myself, because I like to study problems deeply, and it also brings me a lot of pain. For details, you can see my home page, recent questions (some questions that you may never think about).
well, what I want to ask is what exactly is the development mode and production mode of webpack? In other words, what does the development model do and what does the production model do?
some people definitely say that what is used for local development is the development mode. Mode is set to development, and some development configurations, such as devtool, hot updates, are the development mode. It is good that you can see the data in the local browser in time. This is the development mode.
but we"re thinking a little bit deeper, and we all know that webpack packaging depends on package.json, while package.json has a module devDependencies that places development pattern dependencies and a dependencies,package.json that places production pattern dependencies. What"s the relationship between a development pattern devDependencies,webpack.config.js and a development pattern mode:development, in devDependencies,webpack.config.js?
what does this webpack do when it is packaged? Some people say that it is not packaged into the final js, so please take a look at my premise. I put the jquery module in the devDependencies, and finally the packaged js can still run, indicating that the modules in the devDependencies are packaged into the js (no matter what value I set by mode)
to sum up my questions, as I said online, devDependencies is used for development mode packaging and dependencies is used for production mode packaging. I do not see the effect. I only see that no matter what the value of devDependencies and dependencies is, as long as there is a corresponding package in the node_modules folder, it can be successfully packaged in the end. Then what is the significance of devDependencies for development mode packaging and dependencies for production mode packaging? what exactly does it mean on the Internet? where do I misunderstand?
Finally, there is a question, even if what is said on the Internet is true, devDependencies is used for development mode packaging, dependencies is used for production mode packaging, then the webpack module I put in devDependencies can not be used for production mode, how can you package it?{
"name": "vuetest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"jquery": "^3.3.1"
}
}