Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Unexpected token . when loading css from react-flexbox-grid #145

Closed
crdo opened this issue Apr 15, 2018 · 4 comments · Fixed by #228
Closed

Unexpected token . when loading css from react-flexbox-grid #145

crdo opened this issue Apr 15, 2018 · 4 comments · Fixed by #228

Comments

@crdo
Copy link

crdo commented Apr 15, 2018

Following the setup as described in read.me, I am getting:
Unexpected token .
D:\xxxx\xxx\node_modules\flexboxgrid2\flexboxgrid2.css:1
(function (exports, require, module, __filename, __dirname) { .container {
^
what am I doing wrong?

My next.config.js goes as follows:
// next.config.js const withCSS = require("@zeit/next-css"); module.exports = withCSS();

@pencilcheck
Copy link

It seems like SSR works where it puts all required css/scss files into one file in /static/styles.css

However in the client, the loader doesn't seems to be configured correctly.

@pencilcheck
Copy link

I think this issue is related to the externals from server.

#70

Basically I think what happened was that the server didn't bundle them correctly when compiling, therefore the require/import statement in the library becomes a separate file or something that webpack can't understand (the syntax looks like a normal javascript btw if you notice in the error log).

And by changing the rules of externals, it will start working again.

@jupl
Copy link

jupl commented Apr 29, 2018

Getting the same issue. Was expecting to use this module in combination with the normalize.css NPM module and just doing import 'normalize.css', which I have gotten to work in Webpack builds before.

@axeen
Copy link

axeen commented Nov 21, 2019

I had this issue as well, and after days of trying different solutions without luck, I found a module called next-transpile-modules that solved it!

Like so:

const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');
const withTM = require('next-transpile-modules');

module.exports = withCSS(withSass(withTM({
  transpileModules: ['react-flexbox-grid']
})));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants