react-toastify: WebPack CSS import fails with production mode; ok with dev mode

When I compile (my ts) code in production mode

import 'react-toastify/dist/ReactToastify.min.css' 

is ignored:

Screen Shot 2019-03-31 at 4 03 40 PM

when I compile in development mode the css is successfully applied

Screen Shot 2019-03-31 at 4 05 22 PM

Haven’t been able to find a workaround.

Worked fine in 4.x

in package.json:

  "scripts": {
    "dev": "webpack --mode development --config config/webpack.config.js",
    "build": "webpack --mode production --config config/webpack.config.js",

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 21 (8 by maintainers)

Most upvoted comments

I have the same problem with 5.0.0, reverting to 4.5.2 worked.

Kind of a wild guess, but you marked the library as side-effect free, but importing CSS through Webpack (as in import ‘path/styles.css’) IS a side effect. Perhaps it’s because of that? Haven’t checked that but setting:

"sideEffects": [
  "*.css"
]

in package.json would maybe solve this problem.

Fix pushed !

@fkhadra just did, works now 👍

Reverting to react-toastify 4.5.2 fixed the problem…

@fkhadra yes i upgraded to 5.0.1 and all is fine. Good job everyone!