Index: gulpfile.js |
=================================================================== |
--- a/gulpfile.js |
+++ b/gulpfile.js |
@@ -13,25 +13,91 @@ |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with help.eyeo.com. If not, see <http://www.gnu.org/licenses/>. |
*/ |
const gulp = require('gulp'); |
const gutil = require('gulp-util'); |
+const sourcemaps = require('gulp-sourcemaps'); |
+const rename = require('gulp-rename'); |
const sass = require('gulp-sass'); |
const postcss = require('gulp-postcss'); |
const scss = require('postcss-scss'); |
const autoprefixer = require('autoprefixer'); |
+const cleanCSS = require('gulp-clean-css'); |
+const minify = require('gulp-minify'); |
-gulp.task('css', function() { |
- return gulp.src('./static/scss/main.scss') |
- .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) |
- .pipe(sass().on('error', gutil.log)) |
- .pipe(gulp.dest('./static/css')); |
+/****************************************************************************** |
+ * CSS |
+ ******************************************************************************/ |
+ |
+const entryScssFile = 'main'; |
juliandoucette
2017/12/06 15:01:36
NIT: Discussed in-person. I think this is unnecess
ire
2017/12/07 14:54:18
Done.
|
+ |
+gulp.task('css', ['css-default', 'css-minified']); |
+ |
+/* Expanded CSS |
juliandoucette
2017/12/06 15:01:36
NIT: It seems like this comment describes the task
ire
2017/12/07 14:54:23
Ack. This isn't necessary anymore since we are onl
|
+ ******************************************************************************/ |
+ |
+gulp.task('css-default', function() { |
juliandoucette
2017/12/06 15:01:35
I don't think that it's necessary to output both m
ire
2017/12/07 14:54:19
Done.
|
+ return gulp.src(`./static/src/scss/${entryScssFile}.scss`) |
+ .pipe(sourcemaps.init()) |
+ .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) |
+ .pipe(sass().on('error', gutil.log)) |
+ .pipe(sourcemaps.write('./')) |
+ .pipe(gulp.dest('./static/dist/css')) |
+}); |
+ |
+/* Minified CSS |
+ ******************************************************************************/ |
+ |
+gulp.task('css-minified', function() { |
+ return gulp.src(`./static/src/scss/${entryScssFile}.scss`) |
+ .pipe(sourcemaps.init()) |
+ .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) |
+ .pipe(sass({outputStyle: 'compressed'}).on('error', gutil.log)) |
+ .pipe(rename(`${entryScssFile}.min.css`)) |
+ .pipe(sourcemaps.write('./')) |
+ .pipe(gulp.dest('./static/dist/css')); |
}); |
-gulp.task('watch', function() { |
- gulp.watch('./static/scss/**/*.scss', ['css']); |
+/****************************************************************************** |
+ * JS |
+ ******************************************************************************/ |
+ |
+gulp.task('js', function() { |
juliandoucette
2017/12/06 15:01:34
It seems like we should be able to combine the src
ire
2017/12/07 14:54:20
You're right. I didn't think it would preserve the
|
+ return gulp.src(['./static/src/js/*.js']) |
+ .pipe(sourcemaps.init()) |
+ .pipe(minify({ |
+ ext: {src:'.js', min:'.min.js'}, |
+ preserveComments: 'some' |
+ })) |
+ .pipe(sourcemaps.write('./')) |
+ .pipe(gulp.dest('./static/dist/js')) |
}); |
-gulp.task('default', ['css', 'watch']); |
+gulp.task('js-vendor', function() { |
+ return gulp.src(['./static/src/js/vendor/*.js']) |
+ .pipe(sourcemaps.init()) |
+ .pipe(minify({ |
+ ext: {src:'.js', min:'.min.js'}, |
+ preserveComments: 'some' |
+ })) |
+ .pipe(sourcemaps.write('./')) |
+ .pipe(gulp.dest('./static/dist/js/vendor')) |
+}); |
+ |
+/****************************************************************************** |
+ * Watch |
+ ******************************************************************************/ |
+ |
+gulp.task('watch', function() { |
+ gulp.watch('./static/src/scss/**/*.scss', ['css']); |
+ gulp.watch('./static/src/js/*.js', ['js']); |
juliandoucette
2017/12/06 15:01:35
You could watch './static/src/js/**/*.js' instead
ire
2017/12/07 14:54:22
Done.
|
+ gulp.watch('./static/src/js/vendor/*.js', ['js-vendor']); |
+}); |
+ |
+/****************************************************************************** |
+ * Default |
+ ******************************************************************************/ |
+ |
+gulp.task('default', ['css', 'js', 'js-vendor', 'watch']); |