Adding auth target

This commit is contained in:
Belen Curcio
2018-08-08 11:13:44 -03:00
parent 6df52aadbb
commit 577629c65b
8 changed files with 116 additions and 8 deletions
+21 -8
View File
@@ -407,29 +407,42 @@ export default function createWebpackConfig({
/* Webpack config for our embed */
{
...baseConfig,
entry: [
// No polyfills for the embed.
(isProduction && "") ||
require.resolve("react-dev-utils/webpackHotDevClient"),
paths.appEmbedIndex,
// Remove deactivated entries.
].filter(s => s),
entry: {
embed: [
paths.appEmbedIndex,
(isProduction && "") ||
require.resolve("react-dev-utils/webpackHotDevClient"),
],
auth: [
paths.appAuthIndex,
(isProduction && "") ||
require.resolve("react-dev-utils/webpackHotDevClient"),
],
},
output: {
...baseConfig.output,
library: "Talk",
// don't hash the embed, cache-busting must be completed by the requester
// as this lives in a static template on the embed site.
filename: "assets/js/embed.js",
filename: "assets/js/[name].js",
},
plugins: [
...baseConfig.plugins!,
// Generates an `stream.html` file with the <script> injected.
new HtmlWebpackPlugin({
chunks: ["embed"],
filename: "embed.html",
template: paths.appEmbedHTML,
inject: "head",
...htmlWebpackConfig,
}),
new HtmlWebpackPlugin({
chunks: ["auth"],
filename: "auth.html",
template: paths.appAuthHTML,
inject: "head",
...htmlWebpackConfig,
}),
// Makes some environment variables available in index.html.
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
+5
View File
@@ -20,12 +20,17 @@ export default {
appLocales: resolveSrc("locales"),
appThemeVariables: resolveSrc("core/client/ui/theme/variables.ts"),
appThemeVariablesCSS: resolveSrc("core/client/ui/theme/variables.css"),
appStreamHTML: resolveSrc("core/client/stream/index.html"),
appStreamLocalesTemplate: resolveSrc("core/client/stream/locales.ts"),
appStreamIndex: resolveSrc("core/client/stream/index.tsx"),
appEmbedIndex: resolveSrc("core/client/embed/index.ts"),
appEmbedHTML: resolveSrc("core/client/embed/index.html"),
appAuthIndex: resolveSrc("core/client/auth/index.ts"),
appAuthHTML: resolveSrc("core/client/auth/index.html"),
appDistStatic: resolveApp("dist/static"),
appPublic: resolveApp("public"),
appPackageJson: resolveApp("package.json"),
+10
View File
@@ -0,0 +1,10 @@
const path = require("path");
module.exports = {
extends: "../.babelrc.js",
plugins: [
[
"babel-plugin-relay",
{ artifactDirectory: path.resolve(__dirname, "./__generated__") },
],
],
};
+10
View File
@@ -0,0 +1,10 @@
import * as React from "react";
import { StatelessComponent } from "react";
import { Flex } from "talk-ui/components";
const App: StatelessComponent = () => {
return <Flex justifyContent="center">Holaaaaa</Flex>;
};
export default App;
@@ -0,0 +1,10 @@
import * as React from "react";
import { StatelessComponent } from "react";
import App from "../components/App";
const AppContainer: StatelessComponent = () => {
return <App />;
};
export default AppContainer;
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Talk - Auth</title>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no">
</head>
<body>
<div id="app"></div>
</body>
</html>
+36
View File
@@ -0,0 +1,36 @@
import React, { StatelessComponent } from "react";
import ReactDOM from "react-dom";
import {
createContext,
TalkContext,
TalkContextProvider,
} from "talk-framework/lib/bootstrap";
import AppContainer from "./containers/AppContainer";
import { initLocalState } from "./local";
import localesData from "./locales";
// This is called when the context is first initialized.
async function init(context: TalkContext) {
await initLocalState(context.relayEnvironment);
}
async function main() {
// Bootstrap our context.
const context = await createContext({
init,
localesData,
userLocales: navigator.languages,
});
const Index: StatelessComponent = () => (
<TalkContextProvider value={context}>
<AppContainer />
</TalkContextProvider>
);
ReactDOM.render(<Index />, document.getElementById("app"));
}
main();
+9
View File
@@ -0,0 +1,9 @@
/**
* The actual content of this file is being generated by our `locales-loader`.
* Please check `./src/loaders` and the webpack config for more information.
*
* This file only represents the types that gets exported.
*/
import { LocalesData } from "talk-framework/lib/i18n";
export default {} as LocalesData;