From a99f907a7d6cdcc4f0503dd7f4f1a5bd2bd2fc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Thu, 9 Aug 2018 10:16:27 -0300 Subject: [PATCH] updated webpack config --- src/core/build/createWebpackConfig.ts | 122 ++++++++++++++------------ 1 file changed, 65 insertions(+), 57 deletions(-) diff --git a/src/core/build/createWebpackConfig.ts b/src/core/build/createWebpackConfig.ts index 60bb6cbec..ea6d4b196 100644 --- a/src/core/build/createWebpackConfig.ts +++ b/src/core/build/createWebpackConfig.ts @@ -80,6 +80,28 @@ export default function createWebpackConfig({ }, ]; + const localesOptions = { + pathToLocales: paths.appLocales, + + // Default locale if non could be negotiated. + defaultLocale: "en-US", + + // Fallback locale if a translation was not found. + // If not set, will use the text that is already + // in the code base. + fallbackLocale: "en-US", + + // Common fluent files are always included in the locale bundles. + commonFiles: ["framework.ftl", "common.ftl"], + + // Locales that come with the main bundle. Others are loaded on demand. + bundled: ["en-US"], + + // All available locales can be loadable on demand. + // To restrict available locales set: + // availableLocales: ["en-US"], + }; + const additionalPlugins = isProduction ? [ // Minify the code. @@ -214,29 +236,26 @@ export default function createWebpackConfig({ { loader: "locales-loader", options: { - pathToLocales: paths.appLocales, - - // Default locale if non could be negotiated. - defaultLocale: "en-US", - - // Fallback locale if a translation was not found. - // If not set, will use the text that is already - // in the code base. - fallbackLocale: "en-US", - - // Common fluent files are always included in the locale bundles. - commonFiles: ["framework.ftl", "common.ftl"], - - // Locales that come with the main bundle. Others are loaded on demand. - bundled: ["en-US"], - + ...localesOptions, // Target specifies the prefix for fluent files to be loaded. // ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales. target: "stream", - - // All available locales can be loadable on demand. - // To restrict available locales set: - // availableLocales: ["en-US"], + }, + }, + ], + }, + { + test: paths.appAuthLocalesTemplate, + use: [ + // This is the locales loader that loads available locales + // from a particular target. + { + loader: "locales-loader", + options: { + ...localesOptions, + // Target specifies the prefix for fluent files to be loaded. + // ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales. + target: "auth", }, }, ], @@ -380,6 +399,24 @@ export default function createWebpackConfig({ paths.appStreamIndex, // Remove deactivated entries. ].filter(s => s), + auth: [ + // We ship polyfills by default + paths.appPolyfill, + // Include an alternative client for WebpackDevServer. A client's job is to + // connect to WebpackDevServer by a socket and get notified about changes. + // When you save a file, the client will either apply hot updates (in case + // of CSS changes), or refresh the page (in case of JS changes). When you + // make a syntax error, this client will display a syntax error overlay. + // Note: instead of the default WebpackDevServer client, we use a custom one + // to bring better experience for Create React App users. You can replace + // the line below with these two lines if you prefer the stock client: + // require.resolve('webpack-dev-server/client') + '?/', + // require.resolve('webpack/hot/dev-server'), + (isProduction && "") || + require.resolve("react-dev-utils/webpackHotDevClient"), + paths.appAuthIndex, + // Remove deactivated entries. + ].filter(s => s), }, plugins: [ ...baseConfig.plugins!, @@ -391,6 +428,14 @@ export default function createWebpackConfig({ inject: "body", ...htmlWebpackConfig, }), + // Generates an `auth.html` file with the