Skip to content

Commit

Permalink
FIX RN
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Oct 12, 2018
1 parent d468572 commit b15048a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 15 additions & 17 deletions app/react-native/src/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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),
Expand Down
34 changes: 21 additions & 13 deletions app/react-native/src/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit b15048a

Please sign in to comment.