@ -134,6 +134,10 @@ function getSegmentWriteKey({ buildType, environment }) {
throw new Error ( ` Invalid build type: ' ${ buildType } ' ` ) ;
throw new Error ( ` Invalid build type: ' ${ buildType } ' ` ) ;
}
}
const noopWriteStream = through . obj ( ( _file , _fileEncoding , callback ) =>
callback ( ) ,
) ;
module . exports = createScriptTasks ;
module . exports = createScriptTasks ;
function createScriptTasks ( {
function createScriptTasks ( {
@ -143,6 +147,7 @@ function createScriptTasks({
isLavaMoat ,
isLavaMoat ,
livereload ,
livereload ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
policyOnly ,
} ) {
} ) {
// internal tasks
// internal tasks
const core = {
const core = {
@ -185,6 +190,7 @@ function createScriptTasks({
return ` ./app/scripts/ ${ label } .js ` ;
return ` ./app/scripts/ ${ label } .js ` ;
} ) ,
} ) ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
testing ,
testing ,
} ) ,
} ) ,
@ -241,6 +247,7 @@ function createScriptTasks({
runInChildProcess ( subtask , {
runInChildProcess ( subtask , {
buildType ,
buildType ,
isLavaMoat ,
isLavaMoat ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
} ) ,
} ) ,
) ;
) ;
@ -258,6 +265,8 @@ function createScriptTasks({
entryFilepath : ` ./app/scripts/ ${ label } .js ` ,
entryFilepath : ` ./app/scripts/ ${ label } .js ` ,
ignoredFiles ,
ignoredFiles ,
label ,
label ,
testing ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
} ) ;
} ) ;
}
}
@ -272,6 +281,8 @@ function createScriptTasks({
entryFilepath : ` ./app/scripts/ ${ label } .js ` ,
entryFilepath : ` ./app/scripts/ ${ label } .js ` ,
ignoredFiles ,
ignoredFiles ,
label ,
label ,
testing ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
} ) ;
} ) ;
}
}
@ -286,6 +297,8 @@ function createScriptTasks({
entryFilepath : ` ./app/scripts/ ${ label } .js ` ,
entryFilepath : ` ./app/scripts/ ${ label } .js ` ,
ignoredFiles ,
ignoredFiles ,
label ,
label ,
testing ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
} ) ;
} ) ;
}
}
@ -303,6 +316,7 @@ function createScriptTasks({
entryFilepath : ` ./app/scripts/ ${ inpage } .js ` ,
entryFilepath : ` ./app/scripts/ ${ inpage } .js ` ,
label : inpage ,
label : inpage ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
testing ,
testing ,
} ) ,
} ) ,
@ -314,6 +328,7 @@ function createScriptTasks({
entryFilepath : ` ./app/scripts/ ${ contentscript } .js ` ,
entryFilepath : ` ./app/scripts/ ${ contentscript } .js ` ,
label : contentscript ,
label : contentscript ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
testing ,
testing ,
} ) ,
} ) ,
@ -327,6 +342,7 @@ function createFactoredBuild({
devMode ,
devMode ,
entryFiles ,
entryFiles ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
testing ,
testing ,
} ) {
} ) {
@ -346,6 +362,7 @@ function createFactoredBuild({
devMode ,
devMode ,
envVars ,
envVars ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
minify ,
minify ,
reloadOnChange ,
reloadOnChange ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
@ -417,12 +434,17 @@ function createFactoredBuild({
// setup bundle destination
// setup bundle destination
browserPlatforms . forEach ( ( platform ) => {
browserPlatforms . forEach ( ( platform ) => {
const dest = ` ./dist/ ${ platform } / ` ;
const dest = ` ./dist/ ${ platform } / ` ;
pipeline . get ( 'dest' ) . push ( gulp . dest ( dest ) ) ;
const destination = policyOnly ? noopWriteStream : gulp . dest ( dest ) ;
pipeline . get ( 'dest' ) . push ( destination ) ;
} ) ;
} ) ;
} ) ;
} ) ;
// wait for bundle completion for postprocessing
// wait for bundle completion for postprocessing
events . on ( 'bundleDone' , ( ) => {
events . on ( 'bundleDone' , ( ) => {
// Skip HTML generation if nothing is to be written to disk
if ( policyOnly ) {
return ;
}
const commonSet = sizeGroupMap . get ( 'common' ) ;
const commonSet = sizeGroupMap . get ( 'common' ) ;
// create entry points for each file
// create entry points for each file
for ( const [ groupLabel , groupSet ] of sizeGroupMap . entries ( ) ) {
for ( const [ groupLabel , groupSet ] of sizeGroupMap . entries ( ) ) {
@ -496,6 +518,7 @@ function createNormalBundle({
extraEntries = [ ] ,
extraEntries = [ ] ,
ignoredFiles ,
ignoredFiles ,
label ,
label ,
policyOnly ,
modulesToExpose ,
modulesToExpose ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
testing ,
testing ,
@ -516,6 +539,7 @@ function createNormalBundle({
devMode ,
devMode ,
envVars ,
envVars ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
minify ,
minify ,
reloadOnChange ,
reloadOnChange ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
@ -540,7 +564,8 @@ function createNormalBundle({
// setup bundle destination
// setup bundle destination
browserPlatforms . forEach ( ( platform ) => {
browserPlatforms . forEach ( ( platform ) => {
const dest = ` ./dist/ ${ platform } / ` ;
const dest = ` ./dist/ ${ platform } / ` ;
pipeline . get ( 'dest' ) . push ( gulp . dest ( dest ) ) ;
const destination = policyOnly ? noopWriteStream : gulp . dest ( dest ) ;
pipeline . get ( 'dest' ) . push ( destination ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -570,6 +595,7 @@ function setupBundlerDefaults(
devMode ,
devMode ,
envVars ,
envVars ,
ignoredFiles ,
ignoredFiles ,
policyOnly ,
minify ,
minify ,
reloadOnChange ,
reloadOnChange ,
shouldLintFenceFiles ,
shouldLintFenceFiles ,
@ -613,6 +639,7 @@ function setupBundlerDefaults(
setupReloadOnChange ( buildConfiguration ) ;
setupReloadOnChange ( buildConfiguration ) ;
}
}
if ( ! policyOnly ) {
if ( minify ) {
if ( minify ) {
setupMinification ( buildConfiguration ) ;
setupMinification ( buildConfiguration ) ;
}
}
@ -620,6 +647,7 @@ function setupBundlerDefaults(
// Setup source maps
// Setup source maps
setupSourcemaps ( buildConfiguration , { devMode } ) ;
setupSourcemaps ( buildConfiguration , { devMode } ) ;
}
}
}
function setupReloadOnChange ( { bundlerOpts , events } ) {
function setupReloadOnChange ( { bundlerOpts , events } ) {
// Add plugin to options
// Add plugin to options