Skip to content

Commit

Permalink
Upgrade React Native webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-oakes committed May 22, 2017
1 parent b9aa42a commit 7cca6e0
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions app/react-native/src/server/config/defaults/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ import { includePaths } from '../utils';

// Add a default custom config which is similar to what React Create App does.
module.exports = storybookBaseConfig => {
const newConfig = storybookBaseConfig;
const newConfig = { ...storybookBaseConfig };

newConfig.module.loaders = [
...newConfig.module.loaders,
{
test: /\.css?$/,
include: includePaths,
loaders: [
use: [
require.resolve('style-loader'),
require.resolve('css-loader'),
require.resolve('postcss-loader'),
{
loader: require.resolve('postcss-loader'),
options: {
plugins: () => [
autoprefixer({
browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9'],
}),
],
},
},
],
},
{
Expand All @@ -39,19 +49,13 @@ module.exports = storybookBaseConfig => {
},
];

newConfig.postcss = () => [
autoprefixer({
browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9'],
}),
];

newConfig.resolve = {
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
...newConfig.resolve,
alias: {
...((newConfig.resolve && newConfig.resolve.alias) || {}),
// This is to support NPM2
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'),
},
}
};

// Return the altered config
Expand Down

0 comments on commit 7cca6e0

Please sign in to comment.