I
I
ijakparov2016-08-12 12:40:59
RequireJS
ijakparov, 2016-08-12 12:40:59

How to build JS for website using webpack and gulp?

Hello! Not so long ago, I decided to establish the process of developing a front-end for websites. Mastered bower and gulp. I use webpack in gulp with webpack-stream.
The problem is that I can’t assemble the js modular structure together and upload it to the js folder on the site.
I implement JS modularity using the following approach https://habrahabr.ru/post/218485/ and stuff them into folders:
ecff00c710ef4aa188803a1faf040c16.png
The app.js file contains the sequential initialization of all modules:

var App = (function(){
  return {
    init: function(){
      // Инициализация модуля. В ней мы инициализируем все остальные модули на странице
      OrderPopup.init();
      model3D.init();
      colorImages.init();
      sliderMainColorSelect.init();
      mobileColorSelectNav.init();
      colorSelectNav.init(); 
      itemPageCountDown.init();
    }
  }
})();

App.init();

Trying to build a project with webpack results in only app.js getting into the build file. Modules implemented this way can't be built with webpack?
Is it better to write modules using requirejs and build with webpack?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-08-12
@bingo347

Tear off the author of the article for teaching how to use GlobalScope!
I can personally advise you to read about common.js modules (these are "native" modules for webpack and node.js), and this mini-tutorial largescalejs.ru will also be useful

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question