M
M
myskypesla2016-06-15 17:33:28
JavaScript
myskypesla, 2016-06-15 17:33:28

How to catch the path to the current page?

Hello. There is a project where dust js is used to generate templates and load data onto the page.

There is a structure like this:

папка src
---->папка admin
-------->папка admin-page1
------------>папка dust
---------------->example1.dust
---------------->example2.dust
---------------->example3.dust
------------>index.html
---->папка user
-------->папка user-page1
------------>папка dust
---------------->example1.dust
---------------->example2.dust
---------------->example3.dust
------------>index.html


the files example1.dust, example2.dust, example3.dust after running the task in gulp are compiled into example1.js, example2.js, example3.js then

I need to concatenate these files into 1 and put them in the js folder according to their root folders to get this structure:
папка dist
---->папка admin
-------->папка admin-page1
------------>папка js
---------------->templates.js
------------>index.html
---->папка user
-------->папка user-page1
------------>папка js
---------------->templates.js
------------>index.html


The problem is that after concatenation, I naturally get 1 templates.js file from all dust files and it puts this file simply in the root of the dist folder. And I need it to concatenate the files and put them in their root folders, respectively, and get the desired structure.

Tell me how to solve the problem?

I am attaching gulp.task, I immediately say that it is incorrect, I am looking for a solution
gulp.task('dust', function() {
  gulp.src('src/**/*.dust')
    .pipe(dust())
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('../dist'));
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question