nx icon indicating copy to clipboard operation
nx copied to clipboard

Styles are not extracted for React application in production build

Open MiroslavKral opened this issue 3 years ago • 1 comments

Current Behavior

I generate clean React application and generate a few components with global styles with package @nrwl/react:component. These components imports styles directly in TypeScript files by default:

image

When I perform production build, styles are not extracted into separate file, but are included in final bundle:

image

And it is wrong from my point of view and it is problem for our production application too. It is ok for development, but very bad for production.

Expected Behavior

Styles should be extracted into file in production mode.

Steps to Reproduce

There is minimal Github repo with example: https://github.com/MiroslavKral/nx-react-styles Build instructions are in README.

Environment

Node : 14.17.6 OS : win32 x64 npm : 6.14.15

nx : 14.7.5 @nrwl/angular : Not Found @nrwl/cypress : 14.7.5 @nrwl/detox : Not Found @nrwl/devkit : 14.7.5 @nrwl/eslint-plugin-nx : 14.7.5 @nrwl/express : Not Found @nrwl/jest : 14.7.5 @nrwl/js : 14.7.5 @nrwl/linter : 14.7.5 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/nx-cloud : Not Found @nrwl/nx-plugin : Not Found @nrwl/react : 14.7.5 @nrwl/react-native : Not Found @nrwl/schematics : Not Found @nrwl/storybook : 14.7.5 @nrwl/web : 14.7.5 @nrwl/workspace : 14.7.5 typescript : 4.8.3

Local workspace plugins:

Community plugins:

MiroslavKral avatar Sep 19 '22 10:09 MiroslavKral

Is there any problem with provided information?

MiroslavKral avatar Sep 21 '22 07:09 MiroslavKral

What do you mean by extracted? Do you expect your styles file even though they are directly imported by your components not to be included in your components bundle?

ndcunningham avatar Dec 23 '22 18:12 ndcunningham

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Jan 07 '23 00:01 github-actions[bot]

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Mar 21 '23 00:03 github-actions[bot]