I'm having a problem getting the webpack configuration inside the styleguide.config.js
This is my styleguide.config.js:
module.exports = {
title: 'My Guide Project',
components: 'src/components/**/[A-Z]*.js',
showSidebar: true,
pagePerSection: true,
sections: [
{
name: 'Components',
components: () => [
'./src/components/Card/index.js',
],
exampleMode: 'hide', // 'hide' | 'collapse' | 'expand'
usageMode: 'expand'
},
],
webpackConfig: require('./tools/webpack.config.js'), <-- Webpack config
}
But when I run the npx styleguidist server command, I get the following error in the console:
Unexpected token import
The error occurs because it accesses to webpack.config.js and does not interpret "import" at the beginning of the file.
This is the first lines of webpack.config.js
import path from 'path';
import webpack from 'webpack';
import AssetsPlugin from 'assets-webpack-plugin';
import nodeExternals from 'webpack-node-externals';
...
...
Can someone help me with this?
I look in a lot of forums and some say that you have to configure a .babelrc but I haven't got that file in my project.
UPDATE
This is the index.js file
import React, { Component } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import PropTypes from 'prop-types';
import s from './Card.css';
class Card extends Component {
render() {
const {
title,
titleIconClass,
showCardAction,
loading,
cardHeaderLink,
iconCustomStyles,
} = this.props;
return (
<div className={s.smgCard}>
<div
className={`${s.smgCardHeader} ${
cardHeaderLink ? s.cursorPointer : null
}`}
onClick={() => console.log("TEST!")}
role="presentation"
>
<div className={s.smgCardTitle}>
<span className={s.smgCardTitleText}>{title}</span>
<i className={`${s.smgCardIcon} ${titleIconClass}`} style={ iconCustomStyles }/>
</div>
</div>
</div>
);
}
}
export default withStyles(s)(Card);
The error occurs when try to inject styles CSS through withStyles