美文网首页让前端飞前端+React Native开发经验集
创建支持typescript的react项目:react-scr

创建支持typescript的react项目:react-scr

作者: 李留白 | 来源:发表于2018-10-28 15:49 被阅读19次

    最近, create-react-app 发布了2.0 版本,支持了很多新特性,如Babel 7, Sass, and More...
    更新详情 Create React App 2.0: Babel 7, Sass, and More

    最近希望使用在项目中使用typescript和css module。一般来说,

    create-react-app my-app --scripts-version=react-scripts-ts
    

    是可以创建使用typescript的react项目的,但是由于最近刚发布create-react-app 2.0版本,这些新特性react-scripts-ts在正式版中还没有支持,所以使用这种方式后并不会支持css module等新特性。

    逛了create-react-app 的issues, react-scripts-ts的官方github, stackoverflow后终于发现了蛛丝马迹:

    Does react-script-ts support create-react-app and CSS/SCSS Modules?

    https://github.com/wmonk/create-react-app-typescript/pull/409

    作者已经在create-react-app提了pr,同时,如果想在项目中体验,可以

    create-react-app test --scripts-version=react-scripts-ts@4.0.8
    

    注意react-scripts-ts 4.0.8不是稳定正式版。

    相关文章

      网友评论

        本文标题:创建支持typescript的react项目:react-scr

        本文链接:https://www.haomeiwen.com/subject/yzoptqtx.html