Drupal 8 Site using Vue
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.1 KiB

  1. /*eslint strict: ["error", "global"]*/
  2. 'use strict';
  3. //=======================================================
  4. // Include gulp
  5. //=======================================================
  6. var gulp = require('gulp');
  7. //=======================================================
  8. // Include Our Plugins
  9. //=======================================================
  10. var sync = require('browser-sync');
  11. var runSequence = require('run-sequence');
  12. //=======================================================
  13. // Include Our tasks.
  14. //
  15. // Each task is broken apart to it's own node module.
  16. // Check out the ./gulp-tasks directory for more.
  17. //=======================================================
  18. var taskCompile = require('./gulp-tasks/compile.js');
  19. var taskMove = require('./gulp-tasks/move.js');
  20. var taskLint = require('./gulp-tasks/lint.js');
  21. var taskCompress = require('./gulp-tasks/compress.js');
  22. var taskClean = require('./gulp-tasks/clean.js');
  23. //=======================================================
  24. // Compile Our Sass and JS
  25. // We also move some files if they don't need
  26. // to be compiled.
  27. //=======================================================
  28. gulp.task('compile', ['compile:sass', 'compile:js', 'move:js']);
  29. // Compile Sass
  30. gulp.task('compile:sass', function() {
  31. return taskCompile.sass();
  32. });
  33. // Compile JavaScript ES2015 to ES5.
  34. gulp.task('compile:js', function() {
  35. return taskCompile.js();
  36. });
  37. // If some JS components aren't es6 we want to simply move them
  38. // into the dist folder. This allows us to clean the dist/js
  39. // folder on build.
  40. gulp.task('move:js', function() {
  41. return taskMove.js();
  42. });
  43. //=======================================================
  44. // Lint Sass and JavaScript
  45. //=======================================================
  46. gulp.task('lint', ['lint:sass', 'lint:js']);
  47. // Lint Sass based on .sass-lint.yml config.
  48. gulp.task('lint:sass', function () {
  49. return taskLint.sass();
  50. });
  51. // Lint JavaScript based on .eslintrc config.
  52. gulp.task('lint:js', function () {
  53. return taskLint.js();
  54. });
  55. //=======================================================
  56. // Compress Files
  57. //=======================================================
  58. gulp.task('compress', function() {
  59. return taskCompress.assets();
  60. });
  61. //=======================================================
  62. // Clean all directories.
  63. //=======================================================
  64. gulp.task('clean', ['clean:css', 'clean:js']);
  65. // Clean CSS files.
  66. gulp.task('clean:css', function () {
  67. return taskClean.css();
  68. });
  69. // Clean JS files.
  70. gulp.task('clean:js', function () {
  71. return taskClean.js();
  72. });
  73. //=======================================================
  74. // Watch and recompile sass.
  75. //=======================================================
  76. // Pull the sass watch task out so we can use run sequence.
  77. // Pull the sass watch task out so we can use run sequence.
  78. gulp.task('watch:sass', function(callback) {
  79. runSequence(
  80. ['lint:sass', 'compile:sass'],
  81. callback
  82. );
  83. });
  84. // Main watch task.
  85. gulp.task('watch', function() {
  86. // BrowserSync proxy setup
  87. // Uncomment this and swap proxy with your local env url.
  88. // NOTE: for this to work in Drupal, you must install and enable
  89. // https://www.drupal.org/project/link_css. This module should
  90. // NOT be committed to the repo OR enabled on production.
  91. //
  92. // This should work out of the box for work within the style guide.
  93. //
  94. // sync.init({
  95. // open: false,
  96. // proxy: 'http://test.localhost'
  97. // });
  98. // Watch all my sass files and compile sass if a file changes.
  99. gulp.watch(
  100. './src/{global,layout,components}/**/*.scss',
  101. ['watch:sass']
  102. );
  103. // Watch all my JS files and compile if a file changes.
  104. gulp.watch([
  105. './src/{global,layout,components}/**/*.js'
  106. ], ['lint:js', 'compile:js']);
  107. });
  108. //=======================================================
  109. // Default Task
  110. //
  111. // runSequence runs 'clean' first, and when that finishes
  112. // 'lint', 'compile' and 'compress' run at the same time.
  113. //=======================================================
  114. gulp.task('default', function(callback) {
  115. runSequence(
  116. 'clean',
  117. ['lint', 'compile', 'compress'],
  118. callback
  119. );
  120. });