- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4.1k
 
Description
Hello 👋,
Originaly my question was posted to #3761. But the conversations was too complicated to not having its own issue I thought.
@scorsi said at 20 novembre 15:47 UTC+1:
Hello @layershifter,
I had an old code base using old semantic-ui-react setup with webpack which now have a lot of vulnerabilities. I so changed everything to use CRA + CRACO +
@semantic-ui-react/craco-less(without ejecting configurations).
I was looking for the repository of@semantic-ui-react/craco-lessfor posting the issue without success. Hope, this is the right place.I need to use the CSS Modules (to avoid too much codebase changes), I so do in the
craco.config.jsfile :module.exports = { plugins: [{ plugin: require('@semantic-ui-react/craco-less'), options: { cssLoaderOptions: { modules: true, localIdentName: '[local]_[hash:base64:5]', }, }, }], };But still got a weird issue.
If I useimport * as styles from ...orimport styles from ..., I got undefined values.
If I rename my style files tomy-file-name.module.less(as hinted here : https://create-react-app.dev/docs/adding-a-css-modules-stylesheet), I got an error where the webpack loader seems to not recognized the file type :Module parse failed: Unexpected token (1:0). You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.Do you have any clue ?
@layershifter said at 20 novembre 16:03 UTC+1:
You can temporary use
craco-lessfor CSS modules: https://www.npmjs.com/package/craco-less#css-modulesIt should work, can you please check?
@scorsi said at 20 novembre 16:05 UTC+1:
I already tried that but got a weird issue with semantic-ui-less files.
@import (multiple) '../../theme.config'; ^ Can't resolve '../../theme.config' in '/somewhere/node_modules/semantic-ui-less/definitions/modules' in /somewhere/node_modules/semantic-ui-less/definitions/modules/transition.less (line 19, column 0)Which is fixed by
@semantic-ui-react/craco-less, right ?
@rickysullivan said at 20 novembre 20:18 UTC+1:
@layershifter Why not just allow
pluginOptionsto be passed down? See my gist.
I so did my own loader following the @rickysullivan gist. I pass pluginOptions through CracoLessPlugin and it works greatly. It is a really good idea which should be applied to official @semantic-ui-react/craco-less.
I achieved to have my own styles importing as css-module but the all the semantic-ui-less files are also css-module imported and so aren't applied to whole semantic-ui-react components.
I didn't name my files following the official React tips (https://create-react-app.dev/docs/adding-a-css-modules-stylesheet) cause I still got the same error : Module parse failed.
Do you have any clue how I can import my own styles as css-modules but semantic-ui-less files with standard loader (without css-modules enabled) ?
Thanks ! 😊