如何在Meteor 1.3 Beta中使用React Module CSS [英] How to use React Module CSS in Meteor 1.3 beta

查看:105
本文介绍了如何在Meteor 1.3 Beta中使用React Module CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Meteor 1.3版本已经发布,并且 npm软件包即将发布,无需Webpack即可直接使用CSS模块

Meteor 1.3 release is out and a npm package is about to be released allowing a direct use of CSS modules without Webpack

我想使用 https://github.com/gajus/react-css-通过NPM在Meteor 1.3中添加模块.但是自述文件说要使用Webpack.我从没使用过Webpack,因为在我看来,它和Meteor都可以完成相同的构建工作.

I would like to use https://github.com/gajus/react-css-modules in Meteor 1.3 via NPM. But the readme says to use Webpack. I never used Webpack as it seems to me to do the same build job as Meteor.

那么在这种特殊情况下,您是否知道在Meteor 1.3 beta中使用React Module CSS的方法?

So do you know a way, in this specific case, for using React Module CSS in Meteor 1.3 beta?

推荐答案

实际上有用于此的程序包. MDG还考虑在某个阶段将Webpack引入流星核心.是的,它是构建工具.比当前的模块更具模块化和更快的速度.至少在我看来,随着构建工具的发展,它也相当复杂.

There is actually package for this. MDG is also considering bring webpacks on meteor core at some stage. And yes it is build tool. Just more modular and faster than current one. Its also pretty complex as build tools go, at least in my opinion.

仅在流星中包含Webpack>

To have webpacks in meteor just >

meteor add webpack:webpack
meteor remove ecmascript

当您从Webpack中获取ecmascript时,也需要删除它们,并且进行两次安装可能会导致错误.

You need to remove ecmascripts as you get them from webpack as well and having 2 installs can cause errors.

有关更完整的答案,请查看Sam Corcos博客文章,以及Ben Strahan对Meteor 1.3 Beta的评论.我将其用作教程来获取不同的Webpack软件包.

For much more complete answer check Sam Corcos blog post and also Ben Strahan's comment for Meteor 1.3 Beta. I used it as tutorial to get different webpack package up.

https://medium.com/@ SamCorcos/meteor-webpack-from-the-ground-up-f123288c7b75#.phcq5lvm8

对于您提到的软件包,我认为webpack.packages.json应该看起来像这样

For package you mentioned I think webpack.packages.json should look something like this

{
  "private": true,
  "scripts": {
    "start": "webpack-dev-server"
  },
  "devDependencies": {
    "babel-core": "^6.4.5",
    "babel-loader": "^6.2.1",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "babel-preset-stage-0": "^6.3.13",
    "css-loader": "^0.23.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "style-loader": "^0.13.0",
    "webpack": "^2.0.6-beta",
    "webpack-dev-server": "^2.0.0-beta"
  },
  "dependencies": {
    "react": "^0.15.0-alpha.1",
    "react-css-modules": "^3.7.4",
    "react-dom": "^0.15.0-alpha.1"
  }

您可以直接从

https://github.com/gajus/react-css-modules-examples/blob/master/webpack.config.js

这篇关于如何在Meteor 1.3 Beta中使用React Module CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆