Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

chore: better code splitting #413

Merged
merged 8 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dist
filters
package-lock.json
temp-electron-builder.json
temp-package.json
temp-package.json
chunks-entries-map.json
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
"url": "https://github.com/wexond/wexond/issues"
},
"scripts": {
"dev-renderer": "cross-env DEV=1 webpack-dev-server --config webpack.config.renderer.js",
"build-renderer": "webpack --config webpack.config.renderer.js",
"pre-renderer": "cross-env PREBUILD=1 npm run build-renderer",
"dev": "cross-env START=1 npm run watch",
"build": "npm run extensions && concurrently \"webpack --config webpack.config.renderer.js\" \"webpack\" \"webpack --config webpack.config.web.js\"",
"build": "npm run extensions && npm run pre-renderer && concurrently \"npm run build-renderer\" \"webpack\" \"webpack --config webpack.config.web.js\"",
"ci-build": "node scripts/ci-build.js",
"start": "cross-env NODE_ENV='dev' electron .",
"watch": "npm run extensions && concurrently \"cross-env ENV='dev' webpack-dev-server --config webpack.config.renderer.js\" \" cross-env ENV='dev' webpack\" \"cross-env ENV='dev' webpack-dev-server --config webpack.config.web.js\"",
"start": "electron .",
"watch": "npm run extensions && concurrently \"npm run dev-renderer\" \" cross-env DEV=1 webpack\" \"cross-env DEV=1 webpack-dev-server --config webpack.config.web.js\"",
"compile-win32": "npm run build && electron-builder -w",
"compile-darwin": "npm run build && electron-builder -m",
"compile-linux": "npm run build && electron-builder -l",
Expand Down Expand Up @@ -88,6 +91,7 @@
"source-map-support": "^0.5.16",
"styled-components": "^5.0.1",
"terser": "^4.6.4",
"terser-webpack-plugin": "^2.3.5",
"ts-loader": "^6.2.1",
"typescript": "^3.8.3",
"typescript-plugin-styled-components": "^1.4.4",
Expand Down
8 changes: 3 additions & 5 deletions src/renderer/constants/fonts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const fonts = {
robotoRegular: require('~/renderer/resources/fonts/roboto-regular.woff2'),
robotoMedium: require('~/renderer/resources/fonts/roboto-medium.woff2'),
robotoLight: require('~/renderer/resources/fonts/roboto-light.woff2'),
};
export const FONT_ROBOTO_REGULAR = require('~/renderer/resources/fonts/roboto-regular.woff2');
export const FONT_ROBOTO_MEDIUM = require('~/renderer/resources/fonts/roboto-medium.woff2');
export const FONT_ROBOTO_LIGHT = require('~/renderer/resources/fonts/roboto-light.woff2');
33 changes: 33 additions & 0 deletions src/renderer/mixins/typography.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
FONT_ROBOTO_REGULAR,
FONT_ROBOTO_MEDIUM,
FONT_ROBOTO_LIGHT,
} from '../constants';

export const getLetterSpacing = (fontSize: number, tracking: number) =>
tracking / fontSize;

Expand Down Expand Up @@ -102,3 +108,30 @@ export const maxLines = (count: number, lineHeight?: number) => `
-webkit-line-clamp: ${count};
-webkit-box-orient: vertical;
`;

export const injectFonts = () => {
const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${FONT_ROBOTO_REGULAR}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${FONT_ROBOTO_MEDIUM}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${FONT_ROBOTO_LIGHT}) format('woff2');
}
`;

document.head.appendChild(styleElement);
};
27 changes: 2 additions & 25 deletions src/renderer/views/add-bookmark/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,11 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { App } from './components/App';
import { fonts } from '../../constants';
import { ipcRenderer } from 'electron';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
27 changes: 2 additions & 25 deletions src/renderer/views/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,11 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import App from './components/App';
import { fonts } from '../../constants';
import { ipcRenderer } from 'electron';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
27 changes: 2 additions & 25 deletions src/renderer/views/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,11 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { App } from './components/App';
import { fonts } from '../../constants';
import { ipcRenderer } from 'electron';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
27 changes: 2 additions & 25 deletions src/renderer/views/bookmarks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,8 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import App from './components/App';
import { fonts } from '../../constants';
import { injectFonts } from '~/renderer/mixins';

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
29 changes: 2 additions & 27 deletions src/renderer/views/credentials/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,10 @@ import * as ReactDOM from 'react-dom';
import { ipcRenderer } from 'electron';

import { App } from './components/App';
import { fonts } from '../../constants/fonts';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}

@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}

@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
27 changes: 2 additions & 25 deletions src/renderer/views/downloads/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,11 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { App } from './components/App';
import { fonts } from '../../constants';
import { ipcRenderer } from 'electron';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
27 changes: 2 additions & 25 deletions src/renderer/views/find/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,10 @@ import * as ReactDOM from 'react-dom';
import { ipcRenderer } from 'electron';

import { App } from './components/App';
import { fonts } from '../../constants/fonts';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
29 changes: 2 additions & 27 deletions src/renderer/views/form-fill/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,10 @@ import * as ReactDOM from 'react-dom';
import { ipcRenderer } from 'electron';

import { App } from './components/App';
import { fonts } from '../../constants/fonts';
import { injectFonts } from '~/renderer/mixins';

ipcRenderer.setMaxListeners(0);

const styleElement = document.createElement('style');

styleElement.textContent = `
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(${fonts.robotoRegular}) format('woff2');
}

@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(${fonts.robotoMedium}) format('woff2');
}

@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(${fonts.robotoLight}) format('woff2');
}
`;

document.head.appendChild(styleElement);
injectFonts();

ReactDOM.render(<App />, document.getElementById('app'));
Loading