Skip to content

Commit 4014277

Browse files
committed
Concat JS in components folders to components.js
1 parent c15069b commit 4014277

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

gulpfile.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
var settings = {
77
clean: true,
88
scripts: true,
9-
polyfills: true,
9+
componentScripts: true,
10+
polyfills: false,
1011
styles: true,
1112
templates: true,
1213
svgs: true,
@@ -25,6 +26,7 @@ var paths = {
2526
scripts: {
2627
input: 'src/js/*',
2728
polyfills: '.polyfill.js',
29+
components: 'src/components/**/*.js',
2830
output: 'dist/js/'
2931
},
3032
styles: {
@@ -203,14 +205,28 @@ var buildScripts = function (done) {
203205

204206
};
205207

208+
// Concat JS in components
209+
var concatComponentScripts = function (done) {
210+
211+
if (!settings.componentScripts) return done();
212+
213+
// Run tasks on JS files in components folders
214+
return src(paths.scripts.components)
215+
.pipe(sourcemaps.init())
216+
.pipe(concat('components.js'))
217+
.pipe(sourcemaps.write('.'))
218+
.pipe(dest(paths.scripts.output));
219+
};
220+
221+
206222
// Lint scripts
207223
var lintScripts = function (done) {
208224

209225
// Make sure this feature is activated before running
210226
if (!settings.scripts) return done();
211227

212228
// Lint scripts
213-
return src(paths.scripts.input)
229+
return src([paths.scripts.input, paths.scripts.components])
214230
.pipe(jshint())
215231
.pipe(jshint.reporter('jshint-stylish'));
216232

@@ -337,6 +353,7 @@ exports.default = series(
337353
cleanDist,
338354
parallel(
339355
buildScripts,
356+
concatComponentScripts,
340357
lintScripts,
341358
buildStyles,
342359
buildTemplates,

src/components/list/_list.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/list/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.log('List is here.')
1+
console.log('List is here.');

src/components/list/list.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ul {
2+
background-color: lightgreen;
3+
}

src/components/list/list.twig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<pre>List 1</pre>
2-
3-
{{ testvar }}
4-
51
<ul>
62
{% for item in index %}
73
<li>{{ item.name }}</li>

src/js/main/more-code.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('More code!');

src/templates/layouts/main.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<script src="js/detects.js"></script>
2020
<script src="js/another-file.js"></script>
21-
<script src="js/main.polyfills.js"></script>
21+
<script src="js/main.js"></script>
22+
<script src="js/components.js"></script>
2223
</body>
2324
</html>

0 commit comments

Comments
 (0)