Skip to content

Commit

Permalink
Significantly speed up gulp build --css-only (ampproject#9726)
Browse files Browse the repository at this point in the history
Prior to this PR, gulp build --css-only would take ~ 1 minute to run, and end up building a bunch of js files in addition to compiling css.

After this PR, gulp build --css-only takes ~ 0.5 seconds to run (a 100x speed up), and the only output files in build/ after running it are .css, and .css.js files.

Resulting speeds on my workstation:
gulp build --css-only: ~500ms
gulp build: ~1m 45s
gulp dist --fortesting: ~3m 30s

Fixes ampproject#9640
  • Loading branch information
rsimha authored and Aaron Turner committed Jun 6, 2017
1 parent ab38c09 commit b454848
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 154 deletions.
13 changes: 10 additions & 3 deletions build-system/tasks/compile.js
Expand Up @@ -98,7 +98,9 @@ function compile(entryModuleFilenames, outputDir,
var intermediateFilename = 'build/cc/' +
entryModuleFilename.replace(/\//g, '_').replace(/^\./, '');
if (!process.env.TRAVIS) {
util.log('Starting closure compiler for', entryModuleFilenames);
util.log(
'Starting closure compiler for',
util.colors.cyan(entryModuleFilenames));
}
// If undefined/null or false then we're ok executing the deletions
// and mkdir.
Expand Down Expand Up @@ -340,8 +342,13 @@ function compile(entryModuleFilenames, outputDir,
.pipe(gulp.dest(outputDir))
.on('end', function() {
if (!process.env.TRAVIS) {
util.log('Compiled', entryModuleFilename, 'to',
outputDir + '/' + outputFilename, 'via', intermediateFilename);
util.log(
'Compiled',
util.colors.cyan(entryModuleFilename),
'to',
outputDir + '/' + outputFilename,
'via',
intermediateFilename);
}
gulp.src(intermediateFilename + '.map')
.pipe(rename(outputFilename + '.map'))
Expand Down

0 comments on commit b454848

Please sign in to comment.