B
B
beduin012016-02-05 10:13:47
JavaScript
beduin01, 2016-02-05 10:13:47

Do I understand correctly how webpack and NPM work?

Do I understand correctly that webpack is a thing that allows you to bundle all dependencies into one file. And that it can only be used in conjunction with NodeJS.
The situation is such that I regularly meet mentions that you need to use package managers like npm - read it. It comes with NodeJS. But I don't plan to write the server side in JS.
How to be? Is it really difficult to connect a couple of libs to the project with your hands - I don’t think that 20-30 dependencies are used in projects.
Well, let's say what happens if we pack all these 30 dependencies into one file - the file will weigh a lot.
Do I understand correctly that I can't use `require` if I'm not working with NodeJS?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsuhachev, 2016-02-05
@vsuhachev

webpack allows you to preprocess js and other dependencies like styles, graphics, etc. How many files to link - is configured for the specific needs of the project.
Webpack itself runs on a node, but its work is only needed in development mode. The build results do not need nodejs, you get the collected files (js, css, html, ...) that will be returned as static.
Doing the assembly by hand is definitely bad manners. Although, of course, you can do everything by hand, even type an executable in a hex editor, but no one has been doing this for a long time :)
Packing all dependencies into one file - optimization of loading time, saving time on connecting to the server, and the transferred volume will even decrease t .to. a large gzipped file occupies less than 20-30 parts of its components compressed individually.
require you can use if you use webpack. If without it, then see common.js

R
r1ch, 2016-02-05
@r1ch

I use requirejs which pulls all js, html(text - template plugin) files via ajax and caches them. There is also requirejs optimizer, which can minify, glue all dependency files into one file.
Minus the work with css is not very clear and you will have to take it to gulp.
Example: https://github.com/rishatsharafiev/crm/tree/api/pr...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question