diff options
Diffstat (limited to 'gulpfile.babel.js')
-rw-r--r-- | gulpfile.babel.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 193f08813..4932d56f8 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js | |||
@@ -1,7 +1,12 @@ | |||
1 | /* eslint max-len: 0 */ | 1 | /* eslint max-len: 0 */ |
2 | import gulp from 'gulp'; | 2 | import gulp from 'gulp'; |
3 | import gulpIf from 'gulp-if'; | ||
3 | import babel from 'gulp-babel'; | 4 | import babel from 'gulp-babel'; |
4 | import sass from 'gulp-sass'; | 5 | import sass from 'gulp-sass'; |
6 | import csso from 'gulp-csso'; | ||
7 | import terser from 'terser'; | ||
8 | import composer from 'gulp-uglify/composer'; | ||
9 | import htmlMin from 'gulp-htmlmin'; | ||
5 | import server from 'gulp-server-livereload'; | 10 | import server from 'gulp-server-livereload'; |
6 | import { exec } from 'child_process'; | 11 | import { exec } from 'child_process'; |
7 | import dotenv from 'dotenv'; | 12 | import dotenv from 'dotenv'; |
@@ -17,6 +22,8 @@ import * as rawStyleConfig from './src/theme/default/legacy.js'; | |||
17 | 22 | ||
18 | dotenv.config(); | 23 | dotenv.config(); |
19 | 24 | ||
25 | const uglify = composer(terser, console); | ||
26 | |||
20 | const styleConfig = Object.keys(rawStyleConfig).map((key) => { | 27 | const styleConfig = Object.keys(rawStyleConfig).map((key) => { |
21 | const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); | 28 | const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); |
22 | return { | 29 | return { |
@@ -124,6 +131,10 @@ export function mvLernaPackages() { | |||
124 | export function html() { | 131 | export function html() { |
125 | return gulp | 132 | return gulp |
126 | .src(paths.html.src, { since: gulp.lastRun(html) }) | 133 | .src(paths.html.src, { since: gulp.lastRun(html) }) |
134 | .pipe(gulpIf(process.env.NODE_ENV !== 'development', htmlMin({ // Only minify in production to speed up dev builds | ||
135 | collapseWhitespace: true, | ||
136 | removeComments: true | ||
137 | }))) | ||
127 | .pipe(gulp.dest(paths.html.dest)); | 138 | .pipe(gulp.dest(paths.html.dest)); |
128 | } | 139 | } |
129 | 140 | ||
@@ -148,6 +159,9 @@ export function styles() { | |||
148 | includePaths: ['./node_modules', '../node_modules'], | 159 | includePaths: ['./node_modules', '../node_modules'], |
149 | }).on('error', sass.logError), | 160 | }).on('error', sass.logError), |
150 | ) | 161 | ) |
162 | .pipe((gulpIf(process.env.NODE_ENV !== 'development', csso({ // Only minify in production to speed up dev builds | ||
163 | restructure: false, // Don't restructure CSS, otherwise it will break the styles | ||
164 | })))) | ||
151 | .pipe(gulp.dest(paths.styles.dest)); | 165 | .pipe(gulp.dest(paths.styles.dest)); |
152 | } | 166 | } |
153 | 167 | ||
@@ -159,6 +173,7 @@ export function scripts() { | |||
159 | comments: false, | 173 | comments: false, |
160 | }), | 174 | }), |
161 | ) | 175 | ) |
176 | .pipe(gulpIf(process.env.NODE_ENV !== 'development', uglify())) // Only uglify in production to speed up dev builds | ||
162 | .pipe(gulp.dest(paths.scripts.dest)); | 177 | .pipe(gulp.dest(paths.scripts.dest)); |
163 | } | 178 | } |
164 | 179 | ||