8

I want to add the react-date-picker (https://github.com/zippyui/react-date-picker). It says that I need to add the lines

require('react-date-picker/index.css');
var DatePicker = require('react-date-picker');

And using meteorhacks:npm and browserify, I have the module working.

/server/declarations.js

DatePicker = Meteor.npmRequire('react-date-picker');

/lib/app.browserify.js

DatePicker = require('react-date-picker');

But how can I get the CSS file that styles the module to work? I don't know where to put the require('react-date-picker/index.css') without throwing a syntax error. And I can't assign it to a variable, so what do I do?

0

2 Answers 2

5

When Meteor 1.3.2 comes out, you will be able to do, in foo.js:

import "npm-package-name/path/to/style.css";

If you are < 1.3.2, the workaround is to create a package in packages/my-asset-imports like this:

https://gist.github.com/BretFisher/9ea1ba440cb999af9c95

Sign up to request clarification or add additional context in comments.

Comments

0

You don't need meteorhacks:npm!

Update your app to Meteor 1.3 Beta by following this guide: https://github.com/meteor/meteor/issues/5788

Then read here how to use the new features: https://github.com/meteor/meteor/blob/release-1.3/packages/modules/README.md

This fully solves your issue.

1 Comment

I don't see how that solves this issue really? The OP wants to access a CSS file that is included in an NPM module. Currently (also in Meteor 1.3) the only way to do that is by adding the CSS file as @import '../node_modules/react-date-picker/index.css' (or something similar) in the CSS file in your app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.