-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update frontend build process and deps
- Loading branch information
1 parent
5fad201
commit 7983824
Showing
24 changed files
with
16,021 additions
and
17,921 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
const makeHtmlAttributes = (attributes) => { | ||
if (!attributes) { | ||
return '' | ||
} | ||
|
||
const keys = Object.keys(attributes) | ||
// eslint-disable-next-line no-param-reassign | ||
return keys.reduce((result, key) => (result += ` ${key}="${attributes[key]}"`), '') | ||
} | ||
|
||
export const template = async ({ | ||
attributes, | ||
files, | ||
meta, | ||
publicPath, | ||
title | ||
}) => { | ||
const scripts = (files.js || []) | ||
.map(({ fileName }) => { | ||
const attrs = makeHtmlAttributes(attributes.script) | ||
return `<script src="${publicPath}${fileName}"${attrs}></script>` | ||
}) | ||
.join('\n') | ||
|
||
const links = (files.css || []) | ||
.map(({ fileName }) => { | ||
const attrs = makeHtmlAttributes(attributes.link) | ||
return `<link href="${publicPath}${fileName}" rel="stylesheet"${attrs}>` | ||
}) | ||
.join('\n') | ||
|
||
const metas = meta | ||
.map((input) => { | ||
const attrs = makeHtmlAttributes(input) | ||
return `<meta${attrs}>` | ||
}) | ||
.join('\n') | ||
|
||
const htmlFile = fs.readFileSync(path.resolve(__dirname, '../web/public/index.html'), 'utf8') | ||
return htmlFile.replace('${title}', title).replace('${metas}', metas).replace('${links}', links).replace('${scripts}', scripts) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.