1 |
|
2 |
|
3 |
|
4 | 'use strict';
|
5 |
|
6 |
|
7 | const gulp = require('gulp');
|
8 | const env = require('~/helpers/env');
|
9 | const flow = require('~/helpers/flow');
|
10 | const paths = require('~/helpers/paths');
|
11 | const toolbox = require('~/helpers/toolbox');
|
12 | const util = require('~/helpers/util');
|
13 |
|
14 |
|
15 | module.exports = () => {
|
16 |
|
17 |
|
18 | flow.createTask('local-constants', ({ taskName }) => {
|
19 | const streams = [];
|
20 |
|
21 | for (const name of Object.keys(env.bundles)) {
|
22 | const bundle = env.bundles[name];
|
23 |
|
24 | const data = {
|
25 | GENERATION: util.getGeneratedBanner(name, 'text'),
|
26 | [env.id]: env.workflowConfig.version,
|
27 | project: env.packageConfig.name,
|
28 | bundle: name,
|
29 | konstan: util.parseKonstan('local', name, bundle.output)
|
30 | };
|
31 |
|
32 |
|
33 | streams.push(
|
34 | toolbox.vinylStream(paths.filename.konstanLocal, JSON.stringify(data, null, 2))
|
35 | .pipe(toolbox.plumber())
|
36 | .pipe(gulp.dest(`${paths.directory.root}/${bundle.output.konstan}`))
|
37 | .on('finish', () => {
|
38 | toolbox.log(taskName, `'${bundle.output.konstan}/${paths.filename.konstanLocal}' written`, toolbox.filesize(`${paths.directory.root}/${bundle.output.konstan}/${paths.filename.konstanLocal}`));
|
39 | })
|
40 | );
|
41 |
|
42 | }
|
43 |
|
44 | return toolbox.mergeStreams(streams);
|
45 | });
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | flow.createSequence('local', gulp.series('local-constants'), {
|
54 | cleanBundle: ({ bundle }) => {
|
55 | return [`${paths.directory.root}/${bundle.output.konstan}/${paths.filename.konstanLocal}`];
|
56 | }
|
57 | });
|
58 |
|
59 | };
|