Importing CSS files in Isomorphic React Components

前端 未结 10 1319
失恋的感觉
失恋的感觉 2020-11-30 22:01

I have a React application with Components written in ES6 - transpiled via Babel and Webpack.

In some places I would like to include specific CSS files with specific

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 22:37

    Solved With This...

    https://github.com/michalkvasnicak/babel-plugin-css-modules-transform

    $ npm install --save-dev babel-plugin-css-modules-transform
    

    Include plugin in .babelrc

    {
        "plugins": ["css-modules-transform"]
    }
    

    And Import Css..... Like This Anywhere You Want

    const styles = require('./test.css');
    OR
    import css from './styles.css'
    

    Also See This... Apart From Css Files........................................................ . https://www.npmjs.com/package/babel-plugin-transform-assets

提交回复
热议问题