Skip to content

Commit 00b3e88

Browse files
author
Ives van Hoorne
committed
Favicon support
1 parent 98e5316 commit 00b3e88

File tree

6 files changed

+48
-11
lines changed

6 files changed

+48
-11
lines changed

config/webpack.config.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ const config = {
109109
name: 'favicon.ico?[hash:8]',
110110
},
111111
},
112-
// A special case for robots.txt to place it into build root directory.
113-
{
114-
test: /\/robots.txt$/,
115-
include: [paths.src],
116-
loader: 'file-loader',
117-
options: {
118-
name: 'robots.txt?[hash:8]',
119-
},
120-
},
121112
// "url" loader works just like "file" loader but it also embeds
122113
// assets smaller than specified size as data URLs to avoid requests.
123114
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"babel-plugin-transform-decorators-legacy": "^1.3.4",
6767
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
6868
"babel-standalone": "^6.21.1-0",
69+
"base64-loader": "^1.0.0",
6970
"codemirror": "^5.22.0",
7071
"color": "^0.11.4",
7172
"cssnano": "^3.10.0",

src/app/components/Switch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Container = styled.div`
1111
transition: 0.3s ease all;
1212
position: relative;
1313
background-color: ${getColor};
14-
width: 3.5rem;
14+
width: ${({ small }) => small ? 3 : 3.5}rem;
1515
color: rgba(0,0,0,0.5);
1616
border: 1px solid rgba(0,0,0,.1);
1717
padding: 0.5rem;
@@ -35,7 +35,8 @@ const Dot = styled.div`
3535
width: 1rem;
3636
left: 0.1rem;
3737
border-radius: 4px;
38-
transform: translateX(${props => props.right ? 'calc(2rem + 2px)' : '0'});
38+
transform: translateX(${props =>
39+
props.right ? props.small ? 'calc(1.5rem + 2px)' : 'calc(2rem + 2px)' : '0'});
3940
top: ${({ small }) => small ? `calc(0.1rem + 1px)` : `calc(0.1rem)`};
4041
background-color: white;
4142
box-shadow: 0 0 4px rgba(0,0,0,0.2);

src/app/store/entities/sandboxes/create-zip.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ import type { Module } from './modules/entity';
77
import type { Directory } from './directories/entity';
88

99
import README from './README.md';
10+
import favicon from '!base64-loader!./favicon.ico';
11+
12+
const HTML = `<!doctype html>
13+
<html lang="en">
14+
<head>
15+
<meta charset="utf-8">
16+
<meta name="viewport" content="width=device-width, initial-scale=1">
17+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tag above.
20+
It will be replaced with the URL of the \`public\` folder during the build.
21+
Only files inside the \`public\` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running \`npm run build\`.
26+
-->
27+
<title>React App</title>
28+
</head>
29+
<body>
30+
<div id="root"></div>
31+
<!--
32+
This HTML file is a template.
33+
If you open it directly in the browser, you will see an empty page.
34+
35+
You can add webfonts, meta tags, or analytics to this file.
36+
The build step will place the bundled scripts into the <body> tag.
37+
38+
To begin the development, run \`npm start\`.
39+
To create a production bundle, use \`npm run build\`.
40+
-->
41+
</body>
42+
</html>`;
1043

1144
function slugify(text) {
1245
const a = 'àáäâèéëêìíïîòóöôùúüûñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;';
@@ -83,6 +116,13 @@ export default (async function createZip(
83116
.filter(x => x.directoryShortid == null)
84117
.forEach(x => createDirectoryWithFiles(modules, directories, x, src));
85118

119+
const publicFolder = zip.folder('public');
120+
publicFolder.file('index.html', HTML);
121+
122+
publicFolder.file('favicon.ico', favicon, {
123+
base64: true,
124+
});
125+
86126
if (
87127
!modules.find(x => x.directoryShortid == null && x.title === 'README.md')
88128
) {
24.3 KB
Binary file not shown.

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,10 @@ base64-js@^1.0.2:
942942
version "1.2.0"
943943
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1"
944944

945+
base64-loader@^1.0.0:
946+
version "1.0.0"
947+
resolved "https://registry.yarnpkg.com/base64-loader/-/base64-loader-1.0.0.tgz#e530bad88e906dd2a1fad0af2d9e683fa8bd92a8"
948+
945949
batch@0.5.3:
946950
version "0.5.3"
947951
resolved "https://registry.yarnpkg.com/batch/-/batch-0.5.3.tgz#3f3414f380321743bfc1042f9a83ff1d5824d464"

0 commit comments

Comments
 (0)