From b15048aa8f07fe4eb75e9d34250c712383e7cfe9 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 12 Oct 2018 02:57:21 +0200 Subject: [PATCH] FIX RN --- app/react-native/package.json | 2 +- .../src/server/config/webpack.config.js | 32 ++++++++--------- .../src/server/config/webpack.config.prod.js | 34 ++++++++++++------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/app/react-native/package.json b/app/react-native/package.json index c281601c4462..4b83c8ab4832 100644 --- a/app/react-native/package.json +++ b/app/react-native/package.json @@ -51,8 +51,8 @@ "ejs": "^2.6.1", "express": "^4.16.3", "find-cache-dir": "^2.0.0", - "generate-page-webpack-plugin": "^1.1.1", "global": "^4.3.2", + "html-webpack-plugin": "^4.0.0-beta.1", "json5": "^2.1.0", "prop-types": "^15.6.2", "raw-loader": "^0.5.1", diff --git a/app/react-native/src/server/config/webpack.config.js b/app/react-native/src/server/config/webpack.config.js index 18b52b0bfa8e..cb545a5caf5c 100644 --- a/app/react-native/src/server/config/webpack.config.js +++ b/app/react-native/src/server/config/webpack.config.js @@ -4,8 +4,7 @@ import { getEnvironment } from 'universal-dotenv'; import Dotenv from 'dotenv-webpack'; import WatchMissingNodeModulesPlugin from 'react-dev-utils/WatchMissingNodeModulesPlugin'; import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'; - -import GeneratePagePlugin from 'generate-page-webpack-plugin'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; import { getManagerHeadHtml } from '@storybook/core/server'; @@ -31,21 +30,20 @@ const getConfig = options => { publicPath: '/', }, plugins: [ - new GeneratePagePlugin( - { - template: require.resolve('@storybook/core/dist/server/templates/index.html.ejs'), - // eslint-disable-next-line global-require - parser: require('ejs'), - filename: entry => (entry === 'manager' ? 'index' : entry), - }, - { - data: { version }, - headHtmlSnippet: entry => - entriesMeta[entry] ? entriesMeta[entry].headHtmlSnippet : null, - bodyHtmlSnippet: entry => - entriesMeta[entry] ? entriesMeta[entry].bodyHtmlSnippet : null, - } - ), + new HtmlWebpackPlugin({ + filename: `index.html`, + chunksSortMode: 'none', + alwaysWriteToDisk: true, + inject: false, + templateParameters: (compilation, files, o) => ({ + compilation, + files, + options: o, + version, + ...entriesMeta.manager, + }), + template: require.resolve(`@storybook/core/dist/server/templates/index.html.ejs`), + }), new webpack.HotModuleReplacementPlugin(), new CaseSensitivePathsPlugin(), new WatchMissingNodeModulesPlugin(nodeModulesPaths), diff --git a/app/react-native/src/server/config/webpack.config.prod.js b/app/react-native/src/server/config/webpack.config.prod.js index 6393a47dc77b..e13fde963427 100644 --- a/app/react-native/src/server/config/webpack.config.prod.js +++ b/app/react-native/src/server/config/webpack.config.prod.js @@ -2,13 +2,19 @@ import path from 'path'; import webpack from 'webpack'; import { getEnvironment } from 'universal-dotenv'; import Dotenv from 'dotenv-webpack'; -import GeneratePagePlugin from 'generate-page-webpack-plugin'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; import { getManagerHeadHtml } from '@storybook/core/dist/server/utils'; import { version } from '../../../package.json'; import { includePaths, excludePaths } from './utils'; const getConfig = options => { + const entriesMeta = { + manager: { + headHtmlSnippet: getManagerHeadHtml(options.configDir, process.env), + }, + }; + const config = { mode: 'production', bail: true, @@ -27,18 +33,20 @@ const getConfig = options => { publicPath: '/', }, plugins: [ - new GeneratePagePlugin( - { - template: require.resolve('@storybook/core/dist/server/templates/index.html.ejs'), - // eslint-disable-next-line global-require - parser: require('ejs'), - filename: entry => (entry === 'manager' ? 'index' : entry), - }, - { - data: { version }, - headHtmlSnippet: getManagerHeadHtml(options.configDir, process.env), - } - ), + new HtmlWebpackPlugin({ + filename: `index.html`, + chunksSortMode: 'none', + alwaysWriteToDisk: true, + inject: false, + templateParameters: (compilation, files, o) => ({ + compilation, + files, + options: o, + version, + ...entriesMeta.manager, + }), + template: require.resolve(`@storybook/core/dist/server/templates/index.html.ejs`), + }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"', storybookOptions: JSON.stringify(options),