Skip to content

Commit

Permalink
Merge branch 'master' into we-dont-need-to-ship-a-yaml-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
niik authored Apr 4, 2018
2 parents 42f536b + 16d0348 commit 768dc01
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/src/lib/git/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const imageFileExtensions = new Set([
'.gif',
'.ico',
'.webp',
'.bmp',
])

/**
Expand Down Expand Up @@ -307,6 +308,9 @@ function getMediaType(extension: string) {
if (extension === '.webp') {
return 'image/webp'
}
if (extension === '.bmp') {
return 'image/bmp'
}

// fallback value as per the spec
return 'text/plain'
Expand Down
12 changes: 12 additions & 0 deletions app/webpack.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const merge = require('webpack-merge')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const BabelPlugin = require('babel-webpack-plugin')

const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')

const config = {
devtool: 'source-map',
plugins: [
Expand Down Expand Up @@ -52,6 +54,16 @@ const rendererConfig = merge({}, common.renderer, config, {
plugins: [
// Necessary to be able to use ExtractTextPlugin as a loader.
new ExtractTextPlugin('ui.css'),
new BundleAnalyzerPlugin({
// this generates the static HTML file to view afterwards, rather
// than disrupting the user
analyzerMode: 'static',
openAnalyzer: false,
// we can't emit this directly to the dist directory because the
// build script immediately blows away dist after webpack is done
// compiling the source into bundles
reportFilename: 'renderer.report.html',
}),
],
})

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"typescript": "^2.8.1",
"typescript-eslint-parser": "^14.0.0",
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-dev-middleware": "^2.0.3",
"webpack-hot-middleware": "^2.21.0",
"webpack-merge": "^4.1.0",
Expand Down
18 changes: 18 additions & 0 deletions script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ copyStaticResources()
console.log('Parsing license metadata…')
generateLicenseMetadata(outRoot)

moveAnalysisFiles()

const isFork = process.env.CIRCLE_PR_USERNAME
if (process.platform === 'darwin' && process.env.CIRCLECI && !isFork) {
console.log('Setting up keychain…')
Expand Down Expand Up @@ -204,6 +206,22 @@ function copyStaticResources() {
fs.copySync(common, destination, { clobber: false })
}

function moveAnalysisFiles() {
const rendererReport = 'renderer.report.html'
const analysisSource = path.join(outRoot, rendererReport)
if (fs.existsSync(analysisSource)) {
const distRoot = getDistRoot()
const destination = path.join(distRoot, rendererReport)
fs.mkdirpSync(distRoot)
// there's no moveSync API here, so let's do it the old fashioned way
//
// unlinkSync below ensures that the analysis file isn't bundled into
// the app by accident
fs.copySync(analysisSource, destination, { clobber: true })
fs.unlinkSync(analysisSource)
}
}

function copyDependencies() {
// eslint-disable-next-line import/no-dynamic-require
const originalPackage: Package = require(path.join(
Expand Down
Loading

0 comments on commit 768dc01

Please sign in to comment.