Skip to content

Commit

Permalink
feat: Add default webpack config, compile with Babel and support JSX (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Nov 27, 2018
1 parent f958438 commit 645aae5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 37 deletions.
19 changes: 1 addition & 18 deletions examples/material-ui/playroom.config.js
Expand Up @@ -9,22 +9,5 @@ module.exports = {
<Badge badgeContent="2" color="primary">
<Button color="primary">Hello</Button>
</Badge>
`,
webpackConfig: () => ({
module: {
rules: [
{
test: /\.js$/,
include: __dirname,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}
}
]
}
})
`
};
19 changes: 1 addition & 18 deletions examples/reakit/playroom.config.js
Expand Up @@ -9,22 +9,5 @@ module.exports = {
<Button maxWidth="20vmin">Up</Button>
<Button maxWidth="20vmin">Down</Button>
</Group>
`,
webpackConfig: () => ({
module: {
rules: [
{
test: /\.js$/,
include: __dirname,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}
}
]
}
})
`
};
20 changes: 20 additions & 0 deletions lib/makeDefaultWebpackConfig.js
@@ -0,0 +1,20 @@
module.exports = playroomConfig => ({
module: {
rules: [
{
test: /\.jsx?$/,
include: playroomConfig.cwd,
exclude: /node_modules/,
use: {
loader: require.resolve('babel-loader'),
options: {
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-react')
]
}
}
}
]
}
});
3 changes: 2 additions & 1 deletion lib/makeWebpackConfig.js
Expand Up @@ -7,6 +7,7 @@ const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const playroomPath = path.resolve(__dirname, '..');
const examplesPath = path.resolve(playroomPath, 'examples');
const localNodeModulesPath = path.resolve(playroomPath, 'node_modules');
const makeDefaultWebpackConfig = require('./makeDefaultWebpackConfig');

module.exports = (playroomConfig, options) => {
const relativeResolve = requirePath =>
Expand Down Expand Up @@ -103,7 +104,7 @@ module.exports = (playroomConfig, options) => {

const theirConfig = playroomConfig.webpackConfig
? playroomConfig.webpackConfig()
: {};
: makeDefaultWebpackConfig(playroomConfig);

return merge(ourConfig, theirConfig);
};

0 comments on commit 645aae5

Please sign in to comment.