-
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.
- Loading branch information
1 parent
e4ecc36
commit 19b365f
Showing
10 changed files
with
423 additions
and
31 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
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,26 @@ | ||
/* -------------------- | ||
* @overlook/plugin-react-root module | ||
* Create HTML file | ||
* ------------------*/ | ||
|
||
'use strict'; | ||
|
||
// Modules | ||
const escapeHtml = require('escape-html'); | ||
|
||
// Exports | ||
|
||
/** | ||
* Make HTML file content. | ||
* @param {string} path - Path for JS bundle | ||
* @param {string} containerId - ID of container element to render to | ||
* @returns {string} - HTML file content | ||
*/ | ||
module.exports = function createHtml(path, containerId) { | ||
return '<html>\n' | ||
+ '<body>\n' | ||
+ `<div id="${escapeHtml(containerId)}"></div>\n` | ||
+ `<script src="${escapeHtml(path)}"></script>\n` | ||
+ '</body>\n' | ||
+ '</html>\n'; | ||
}; |
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,26 @@ | ||
/* -------------------- | ||
* @overlook/plugin-react-root module | ||
* Create root file | ||
* ------------------*/ | ||
|
||
'use strict'; | ||
|
||
// Exports | ||
|
||
const reactPath = require.resolve('@overlook/plugin-react/react'), | ||
reactDomPath = require.resolve('react-dom'); | ||
|
||
const {stringify} = JSON; | ||
|
||
/** | ||
* Make router file content. | ||
* @param {Object} file - File object for router | ||
* @param {string} containerId - ID of container element to render to | ||
* @returns {string} - Router root file content | ||
*/ | ||
module.exports = function createRoot(file, containerId) { | ||
return `import React from ${stringify(reactPath)};\n` | ||
+ `import {render} from ${stringify(reactDomPath)};\n\n` | ||
+ `import Route from ${stringify(file.path)};\n\n` | ||
+ `render(<Route />, document.getElementById(${stringify(containerId)}));\n`; | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.