-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Showing
10 changed files
with
138 additions
and
105 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
110 changes: 60 additions & 50 deletions
110
app/react-native/src/server/config/webpack.config.prod.js
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 |
---|---|---|
@@ -1,57 +1,67 @@ | ||
import path from 'path'; | ||
import webpack from 'webpack'; | ||
import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
import { OccurenceOrderPlugin, includePaths, excludePaths } from './utils'; | ||
|
||
const config = { | ||
bail: true, | ||
devtool: '#cheap-module-source-map', | ||
entry: { | ||
manager: [path.resolve(__dirname, '../../manager')], | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: 'static/[name].bundle.js', | ||
// Here we set the publicPath to ''. | ||
// This allows us to deploy storybook into subpaths like GitHub pages. | ||
// This works with css and image loaders too. | ||
// This is working for storybook since, we don't use pushState urls and | ||
// relative URLs works always. | ||
publicPath: '/', | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }), | ||
new webpack.optimize.DedupePlugin(), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
screw_ie8: true, | ||
warnings: false, | ||
}, | ||
mangle: { | ||
screw_ie8: true, | ||
}, | ||
output: { | ||
comments: false, | ||
screw_ie8: true, | ||
}, | ||
}), | ||
], | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.jsx?$/, | ||
loader: require.resolve('babel-loader'), | ||
query: require('./babel.prod.js'), // eslint-disable-line | ||
include: includePaths, | ||
exclude: excludePaths, | ||
}, | ||
const getConfig = options => { | ||
const config = { | ||
bail: true, | ||
devtool: '#cheap-module-source-map', | ||
entry: { | ||
manager: [path.resolve(__dirname, '../../manager')], | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: 'static/[name].bundle.js', | ||
// Here we set the publicPath to ''. | ||
// This allows us to deploy storybook into subpaths like GitHub pages. | ||
// This works with css and image loaders too. | ||
// This is working for storybook since, we don't use pushState urls and | ||
// relative URLs works always. | ||
publicPath: '/', | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
filename: 'index.html', | ||
data: { | ||
options: JSON.stringify(options), | ||
}, | ||
template: require.resolve('../index.html.ejs'), | ||
}), | ||
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }), | ||
new webpack.optimize.DedupePlugin(), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
screw_ie8: true, | ||
warnings: false, | ||
}, | ||
mangle: { | ||
screw_ie8: true, | ||
}, | ||
output: { | ||
comments: false, | ||
screw_ie8: true, | ||
}, | ||
}), | ||
], | ||
}, | ||
}; | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.jsx?$/, | ||
loader: require.resolve('babel-loader'), | ||
query: require('./babel.prod.js'), // eslint-disable-line | ||
include: includePaths, | ||
exclude: excludePaths, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
// Webpack 2 doesn't have a OccurenceOrderPlugin plugin in the production mode. | ||
// But webpack 1 has it. That's why we do this. | ||
if (OccurenceOrderPlugin) { | ||
config.plugins.unshift(new OccurenceOrderPlugin()); | ||
} | ||
// Webpack 2 doesn't have a OccurenceOrderPlugin plugin in the production mode. | ||
// But webpack 1 has it. That's why we do this. | ||
if (OccurenceOrderPlugin) { | ||
config.plugins.unshift(new OccurenceOrderPlugin()); | ||
} | ||
}; | ||
|
||
export default config; | ||
export default getConfig; |
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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Storybook for React</title> | ||
<style> | ||
/* Styling the fuzzy search box placeholders */ | ||
.searchBox::-webkit-input-placeholder { /* Chrome/Opera/Safari */ | ||
color: #ddd; | ||
font-size: 16px; | ||
} | ||
.searchBox::-moz-placeholder { /* Firefox 19+ */ | ||
color: #ddd; | ||
font-size: 16px; | ||
} | ||
.searchBox:focus{ | ||
border-color: #EEE !important; | ||
} | ||
.btn:hover{ | ||
background-color: #eee | ||
} | ||
</style> | ||
</head> | ||
<body style="margin: 0;"> | ||
<div id="root"></div> | ||
<script> | ||
window.storybookOptions = <%= htmlWebpackPlugin.options.data.options %>; | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
// load the default config generator. | ||
|
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,27 @@ | ||
const webpack = require('webpack'); | ||
|
||
// load the default config generator. | ||
const genDefaultConfig = require('@storybook/react-native/dist/server/config/defaults/webpack.config.js'); | ||
|
||
// Export a function. Accept the base config as the only param. | ||
module.exports = (storybookBaseConfig, configType) => { | ||
// configType has a value of 'DEVELOPMENT' or 'PRODUCTION' | ||
// You can change the configuration based on that. | ||
// 'PRODUCTION' is used when building the static version of storybook. | ||
|
||
const config = genDefaultConfig(storybookBaseConfig, configType); | ||
|
||
// Make whatever fine-grained changes you need | ||
config.plugins.push( | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor', | ||
minChunks(module) { | ||
// this assumes your vendor imports exist in the node_modules directory | ||
return module.context && module.context.indexOf('node_modules') !== -1; | ||
}, | ||
}) | ||
); | ||
|
||
// Return the altered config | ||
return config; | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
// load the default config generator. | ||
|