mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 01:59:57 +00:00
Use strict TypeScript, enable TSLint, update all types to work in strict mode.
This commit is contained in:
32
src/index.tsx
Normal file
32
src/index.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { h, render } from 'preact';
|
||||
import './lib/fix-pmc';
|
||||
import './style';
|
||||
import App from './components/app';
|
||||
|
||||
// Find the outermost Element in our server-rendered HTML structure.
|
||||
let root = document.querySelector('[prerender]') || undefined;
|
||||
|
||||
// "attach" the client-side rendering to it, updating the DOM in-place instead of replacing:
|
||||
root = render(<App />, document.body, root);
|
||||
|
||||
// In production, this entire condition is removed.
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// Enable support for React DevTools and some helpful console warnings:
|
||||
require('preact/debug');
|
||||
|
||||
// When an update to any module is received, re-import the app and trigger a full re-render:
|
||||
module.hot.accept('./components/app', () => {
|
||||
import('./components/app').then(({ default: App }) => {
|
||||
root = render(<App />, document.body, root);
|
||||
});
|
||||
});
|
||||
} else if ('serviceWorker' in navigator && location.protocol === 'https:') {
|
||||
addEventListener('load', () => {
|
||||
navigator.serviceWorker.register(__webpack_public_path__ + 'sw.js');
|
||||
});
|
||||
}
|
||||
|
||||
/** @todo SSR */
|
||||
// if (typeof module==='object') {
|
||||
// module.exports = app;
|
||||
// }
|
||||
Reference in New Issue
Block a user