recently, in the process of learning webpack4, I went deep into the details that I had never paid attention to before, and found some problems that I didn"t quite understand. Now my package.json configuration file refers to webpack,webpack-cli,html-webpack-plugin,clean-webpack-plugin, which are all tools. Needless to say, I packed them into devDependencies, and then when I was developing index.js, I introduced jquery, and I began to think, This is theoretically supposed to be in dependencies, because the production mode requires it, but what if I put it in devDependencies? The following is the conclusion I have drawn from my constant experiments (each time, to ensure accuracy, completely delete the node_modules folder and re-install one by one):
1. Put it in devDependencies, set mode to development (development mode), and the packaged files can be used normally using jquery;
2. Put it in devDependencies, set mode to production (production mode), and the packaged files can be used normally using jquery;
3. Put it in dependencies, set mode to development (development mode), and the packaged files can be used normally using jquery;
4. Put it in dependencies, set mode to production (production mode), and the packaged files can be used normally with jquery;
{
"name": "vuetest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --config webpack.prod.js",
"start": "webpack-dev-server --open --config webpack.dev.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"html-webpack-plugin": "^3.2.0",
"jquery": "^3.3.1",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
}
}
what?
I"m starting to wonder about life. I"m starting to wonder what dependencies and devDependencies are for, because I can"t see the difference, what"s the meaning of its existence, and what are the corresponding production and development patterns? Please don"t hesitate to give me your advice. Thank you very much!