Skip to content

Question about importing css and scss. #126

@davetbo-amzn

Description

@davetbo-amzn

Hello,

I'm trying to use your boilerplate to create a boilerplate of Electron, React, Redux, and Amplify. However, when I do this in my Javascript:
import '@aws-amplify/ui-react/styles.css';

and then do yarn run develop, it compiles OK but I get this in the console output:
Uncaught Error: Cannot find module '@aws-amplify/ui-react/styles.css

So then I figured maybe I should do a .babelrc like this:

{
    "plugins": [
      ["react-css-modules", {
        "filetypes": {
            ".css": {
                "syntax": "postcss-scss"
            }
        }
      }]
    ]
  }

With that .babelrc enabled I get this error when I run yarn run develop:

 'dev-build-scripts' errored after 759 ms
 TypeError in plugin "gulp-babel"
electron-react-redux-boilerplate/app/renderer/components/App.js: Class extends value undefined is not a constructor or null

My App.js file is as follows:

import React, { Component } from 'react';
//import { Amplify, Auth } from 'aws-amplify';
//import { withAuthenticator, Button, CheckboxField } from '@aws-amplify/ui-react';
//import '@aws-amplify/ui-react/styles.css';
//import awsExports from '../../aws-exports';
import './css/App.css'; 

//Amplify.configure(awsExports);
//Auth.configure(awsExports);

class App extends Component {
  constructor(props) {
    super(props);
    this.props = props;
  }
  render() {
    return (
      <div className="eaContainer">
      <h2>Electron React Amplify Demo</h2>
      {/* <CheckboxField
        label="Launch at startup: "
        labelPosition="start"
        type="checkbox"
        onChange=''
        className="eaInput"
        checked=''
    />*/}
      
      <span>Selected analytics tool: {false}</span>
      <a onClick={false}>Select analytics tool</a>
  
      {/*<Button
        className="eaButton"
        variation="primary"
        onClick={false}
      >
        Start Analytics Tool
      </Button>
      <Button
        className="eaButton"
        onClick={this.props.signOut}
      >
        Sign out
  </Button>*/}
    </div>
    );
  }
}
//export default withAuthenticator(App);
export default App;

As you can see I commented out everything Amplify-specific. I should note that './css/App.css' is plain CSS. I get the same result if I try to uncomment the line that imports '@aws-amplify/ui-react/styles.css' so I know I can't import things from node modules either.

I'm sure it's because I'm not super familiar with Gulp and Babel, but could you provide an explicit example where importing CSS and SCSS works and gets compiled down to regular CSS either way, like it would do if I did npx create-react-app? I'm an SA, not an SDE :D.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions