O
O
Old Odessa2017-09-27 15:22:01
JavaScript
Old Odessa, 2017-09-27 15:22:01

Why del-cli w webpack?

The question is, According to the tutorial, you need to do

"scripts": {
    "prebuild": "del-cli dist -f",
    "build": "webpack src/main.js dist/bundle.js",
    "execute": "node dist/bundle.js",
    "start": "npm run build -s && npm run execute -s"
  },

Why do you need prebuild at all if all the files inside dist are replaced anyway. Or I do not understand something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-09-27
@maxfarseer

There can be many things in the dist directory . Including some old copied files that may interfere / be not needed in the new build (which is more likely). Therefore, cleaning up the directory before creating new files is not a bad idea.
For example, you break your big bundle into pieces.
At the time of the build, you got 30 pieces.
Then you removed some code, and now you have 29 pieces. They will replace everything inside dist, but the 30th one will remain.
And if you still had a name by type: name + hash / or something else, then you will have just a bunch of rubbish in dist.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question