A
A
Artem Rumyantsev2018-05-16 09:56:53
JavaScript
Artem Rumyantsev, 2018-05-16 09:56:53

How to assemble a JS object from several files according to a template?

Is there any tool that allows you to do this:

there is a main.js target file that defines an object or function, like this:

main('jquery', function($) {
  let script = {
   init () {
    {{init.js}}
   }
   load () {
    {{load.js}}
   }
   render () {
      {{render.html}}
    }
  };

 return script;
});


That is, this file is assembled from other files init.js, render.html, etc.

Is it possible to implement this through Webpack, Gulp, Grunt? If yes, what settings to use or plugins.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-05-16
@rockon404

So now nobody writes. Don't reinvent the wheel.
Use ES6 modules and Webpack .
Judging by the need to render html , you should look towards modern front-end frameworks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question