2

I am building an app which uses client-server comunications and server-google cloud platform comunications by using socket.io. For the front-end part I'm using React where I have two components App and Touch. In the future I'll change project structures but rigth now it looks like this

My project structure is the following one:

nodemodulesFolder
publicFolder
  jsFolder
     client.js
     socket.io.js
     socket.io.js
     socket.io.js.map
     touch.js
  viewFolder
     App.js
     index.css
     Touch.js
  index.js
  routes.js
.dockerignore
.env
.gitignore
deployment.yaml
Dockerfile
index.js
ingress.yaml
Jenkinsfike
package.json
package-lock.json
server.js
webpack.config.js

My CSS file looks like this:

body { 
    font-family: sans-serif;
}



p {
    color: black;
}

a {
    font-weight: bold;
    text-decoration: none;
    color: #2a2a2a;
}

a:visited {
    font-weight: normal;
}

a:hover {
    text-decoration: underline;
}


.wrapper {
    width: 90vw;
    padding-top: 100px;
    margin: auto;
    width: 50%;
    margin-bottom: 160px;
}

.greyText {
    opacity: 0.4;
}

.buttonWrapper{
    margin: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 140px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-top: 2px solid #ddd;
}

#ResultText {
    width: 80vw;
    margin-bottom: 100%;
    overflow: auto;
}

#ResultText span {
    display: inline-block;
    margin-top: 10px;
}

#sessionSpeechData {
    width: 80vw;
}

#sessionSpeechData span {
    display: inline-block;
    margin-top: 10px;
}

.nl-Adjective {
    background-color: #1ada47;
    padding: 3px;
    border-radius: 5px;
}

.nl-Noun {
    background-color: #151ffa;
    padding: 3px;
    border-radius: 5px;
    color: white;
}

.nl-Verb {
    background-color: #ff1616;
    padding: 3px;
    border-radius: 5px;
}


.hiddenForms {
    opacity: 0.2;
}

h1 {
    color: black;
} 


/* ==========================================================================
   Media Queries
   ========================================================================== */

/*==========  Non-Mobile First Method  ==========*/

/*Above */

@media only screen and (min-width: 1201px) {} 

/* Large Devices, Wide Screens */

@media only screen and (max-width: 1200px) {}

/* Medium Devices, Desktops */

@media only screen and (max-width: 992px) {}

/* Small Devices, Tablets */

@media only screen and (max-width: 768px) {}

/* Extra Small Devices, Phones */

@media only screen and (max-width: 480px) {}

/* Custom, iPhone Retina */

@media only screen and (max-width: 320px) {}

@media print, (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {}

/* ==========================================================================
   Helper classes
   ========================================================================== */

.hidden {
    display: none !important;
    visibility: hidden;
}

.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

.visuallyhidden.focusable:active, .visuallyhidden.focusable:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
}

.invisible {
    visibility: hidden;
}

.clearfix:before, .clearfix:after {
    content: " ";
    display: table;
}

.clearfix:after {
    clear: both;
}

.clearfix {
    *zoom: 1;
}

/* ==========================================================================
   Print styles
   ========================================================================== */

@media print {
    *, *:before, *:after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    a, a:visited {
        text-decoration: underline;
    }
    a[href]:after {
        content: " (" attr(href) ")";
    }
    abbr[title]:after {
        content: " (" attr(title) ")";
    }
    a[href^="#"]:after, a[href^="javascript:"]:after {
        content: "";
    }
    pre, blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }
    thead {
        display: table-header-group;
    }
    tr, img {
        page-break-inside: avoid;
    }
    img {
        max-width: 100% !important;
    }
    p, h2, h3 {
        orphans: 3;
        widows: 3;
    }
    h2, h3 {
        page-break-after: avoid;
    }
}


.btn {
    background-color: #4285f4;
    color: #fff;
    width:140px;
    height:100px;
  }

  .btn:hover {
    background-color: #296CDB;
  }

  .btn:focus {
    background-color: #0F52C1;
    outline: 0;
  }

  .btn:active {
    background-color: #0039A8;
  }


  #startRecButton {
      background-color: #1ada47;
      margin-right:80px; 
  }


  #startRecButton:hover {
    background-color: #1ada47;
  }

  #startRecButton:focus {
    background-color: rgb(62, 180, 38);
    outline: 0;
  }

  #startRecButton:active {
    background-color: rgb(64, 114, 44);
  } 

But I get the following error in the compiling time:

/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babel-core/lib/transformation/file/index.js:558
      throw err;
      ^

SyntaxError: /Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/public/views/index.css: Unexpected token, expected ; (1:5)
> 1 | body {
    |      ^
  2 |     font-family: sans-serif;
  3 | }
  4 |
    at Parser.pp$5.raise (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:4454:13)
    at Parser.pp.unexpected (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:1761:8)
    at Parser.pp.semicolon (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:1742:38)
    at Parser.pp$1.parseExpressionStatement (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:2236:8)
    at Parser.parseExpressionStatement (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:5934:20)
    at Parser.pp$1.parseStatement (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:1911:17)
    at Parser.parseStatement (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:5910:22)
    at Parser.pp$1.parseBlockBody (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:2268:21)
    at Parser.pp$1.parseTopLevel (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:1778:8)
    at Parser.parse (/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/node_modules/babylon/lib/index.js:1673:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `webpack && node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/raulvilloravalencia/.npm/_logs/2018-09-28T10_17_39_236Z-debug.log

My webpack.config.js file is the following:

'use strict'

module.exports = {
  entry: __dirname + '/public/index.js',
  output: {
    path: __dirname + '/public/',
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015']
        }
      },
      { test: /\.css$/,
        use:[ {loader: 'css-loader'} ]
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.jsx']
  }
};
1
  • 3
    Hi Joe, could you please post the contents of your webpack.config.js file? Commented Sep 28, 2018 at 10:35

2 Answers 2

3

You also need style-loader

Install style-loader first

npm install style-loader --save-dev

Webpack 3 version

  { test: /\.css$/,
    use:[ {loader: 'style-loader!css-loader'} ]
  }

webpack 4 version

  {
     test: /\.css$/,
     loader: "style-loader!css-loader"
  }
Sign up to request clarification or add additional context in comments.

4 Comments

After installing style-loader and changing the webpack with the code you provide, do I need to change the components?
That's what I think I'm still getting the same error.
Have you restarted your react app after adding the config?
Yes, I've started again.
0

Show content of webpack.config.js. It seems you're missing css/style loaders. THIS should help you set it up properly.

{
   module: {
     rules: [
       {
         test: /\.css$/,
         use: [
           { loader: "style-loader" },
           { loader: "css-loader" }
         ]
       }
    ]
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.