Skip to content

Commit

Permalink
Merge pull request #343 from andreban/lighthouse-chart-rollup
Browse files Browse the repository at this point in the history
Create rollup config for lighthouse-chart
  • Loading branch information
juliantoledo authored Mar 17, 2017
2 parents 90d466f + d2fef2a commit ce464b7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/coverage
/third_party
/public/js/gulliver.js
/public/js/lighthouse-chart.js
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ npm-debug.log
key.json
public/js/gulliver.js
public/js/gulliver.js.map
public/js/lighthouse-chart.js
public/js/lighthouse-chart.js.map
public/firebase-messaging-sw.js

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"scripts": {
"start": "node app.js",
"prestart": "rollup -c && npm run generate-msg-sw",
"prestart": "rollup -c rollup-config/gulliver.js && rollup -c rollup-config/lighthouse-chart.js && npm run generate-msg-sw",
"monitor": "nodemon app.js",
"deploy": "npm run prestart && gcloud app deploy app.yaml",
"mocha": "_mocha test/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/* global google */
/* eslint-env browser */
import Loader from './loader';

/**
* Use to make the API request to get the Lighthouse chart data for a PWA.
Expand All @@ -25,7 +26,7 @@ class LighthouseChart {

constructor() {
this.chartElement = document.getElementById('chart');
this.loader = new window.Loader(this.chartElement, 'dark-primary-background');
this.loader = new Loader(this.chartElement, 'dark-primary-background');
}

load() {
Expand Down Expand Up @@ -66,7 +67,5 @@ class LighthouseChart {
console.error('There was an error drawing the chart!', err);
});
}

}

new LighthouseChart().load();
4 changes: 0 additions & 4 deletions public/js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,4 @@ class Loader {
}

}

// HACK: attach loader class to window object so that chart.js (which is not
// managed by rollup) can use the loader.
window.Loader = Loader;
export default Loader;
File renamed without changes.
26 changes: 26 additions & 0 deletions rollup-config/lighthouse-chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonsjs from 'rollup-plugin-commonjs';

export default {
entry: './public/js/lighthouse-chart.es6.js',
plugins: [
babel({exclude: 'node_modules/**'}),
uglify(),
nodeResolve(),
commonsjs()
],
// Quiet warning: https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
context: 'window',
targets: [
{
dest: './public/js/lighthouse-chart.js',
// Fixes 'navigator' not defined when using Firebase and strict mode:
// http://stackoverflow.com/questions/31221357/webpack-firebase-disable-parsing-of-firebase
useStrict: false,
format: 'iife',
sourceMap: true
}
]
};

0 comments on commit ce464b7

Please sign in to comment.