Skip to content

Commit

Permalink
Added LZMA asset for #746
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpen committed Mar 14, 2019
1 parent 85b3b13 commit 13c07e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
18 changes: 17 additions & 1 deletion js/grunt/buildRunnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const copyDirectory = require( './copyDirectory' );
const copySupplementalPhetioFiles = require( './phet-io/copySupplementalPhetioFiles' );
const fs = require( 'fs' );
const generateThumbnails = require( './generateThumbnails' );
const generateTwitterCard = require( './generateTwitterCard' );
const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate' );
Expand All @@ -30,6 +31,7 @@ const getTitleStringKey = require( './getTitleStringKey' );
const grunt = require( 'grunt' );
const jimp = require( 'jimp' );
const loadFileAsDataURI = require( '../common/loadFileAsDataURI' );
const lzma = require( 'lzma-native' ); // eslint-disable-line require-statement-match
const minify = require( './minify' );
const nodeHTMLEncoder = require( 'node-html-encoder' ); // eslint-disable-line require-statement-match
const packageRunnable = require( './packageRunnable' );
Expand Down Expand Up @@ -187,13 +189,27 @@ module.exports = async function( repo, minifyOptions, instrument, allHTML, brand
includeAllLocales: true,
isDebugBuild: false
}, commonInitializationOptions ) );
grunt.file.write( `${buildDir}/${repo}_all_${brand}.html`, packageRunnable( {

const allHTMLFilename = `${buildDir}/${repo}_all_${brand}.html`;

grunt.file.write( allHTMLFilename, packageRunnable( {
repo: repo,
stringMap: stringMap,
htmlHeader: htmlHeader,
locale: ChipperConstants.FALLBACK_LOCALE,
scripts: [ initializationScript, splashScript, mipmapsJavaScript, ...productionPreloads, chipperStringsScript, productionJS ]
} ) );

try {
// Create LZMA compressed asset
fs.createReadStream( allHTMLFilename )
.pipe( lzma.createCompressor() )
.pipe( fs.createWriteStream( `${allHTMLFilename}.xz` ) );
}
catch ( error ) {
grunt.log.error( error );
throw new Error( 'lzma compression failed' );
}
}

// Debug build (always included)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
"jscpd": "^0.6.18",
"jsdoc": "~3.5.5",
"lodash": "^4.17.10",
"lzma-native": "^4.0.3",
"md5": "~2",
"node-html-encoder": "~0.0.2",
"pngjs": "~0.4.0",
"qunit": "~2.4.1",
"request": "^2.87.0",
"request-promise-native": "~1.0.5",
"request-promise-native": "^1.0.7",
"requirejs": "~2.3.5",
"uglify-es": "~3.1.10"
},
"eslintConfig": {
"extends": "../chipper/eslint/sim_eslintrc.js"
}
}
}

0 comments on commit 13c07e6

Please sign in to comment.