babel-plugin-react-css-modules icon indicating copy to clipboard operation
babel-plugin-react-css-modules copied to clipboard

"ParseError: Unexpected token" - using v3.3.3 + Browserify v16.1.0

Open basher opened this issue 6 years ago • 2 comments

Please see https://github.com/basher/react-no-webpack

This is a simple React UI library POC. I want to use CSS Modules without using Webpack.

The error happens when parsing https://github.com/basher/react-no-webpack/blob/master/src/lib/components/WidgetCSS/WidgetCSS.css

This is imported inside https://github.com/basher/react-no-webpack/blob/master/src/lib/components/WidgetCSS/WidgetCSS.js

I'm simply executing build or watch commands from "package.json" - e.g. browserify ./src/index.js -o ./build/bundle.js -t babelify

basher avatar Mar 02 '18 17:03 basher

The docs for this plugin clearly state: Note: The default configuration should work out of the box with the css-loader.

So do I need to still add any other config options in my .babelrc to parse CSS files?


I've done some more investigation...

"npm run lib" ouptuts https://github.com/basher/react-no-webpack/blob/master/lib/components/WidgetCSS/WidgetCSS.js with generated className property. So Babel works OK.

The issue is with "run build" and "run watch" commands which use Browserify + Babelify.

KITSKevinBonett avatar Mar 05 '18 11:03 KITSKevinBonett

I have a workaround now - I've replaced babel-plugin-react-css-modules with css-modulesify.

"package.json" setup here - https://github.com/basher/react-no-webpack/blob/master/package.json

KITSKevinBonett avatar Mar 13 '18 09:03 KITSKevinBonett