简体   繁体   中英

How do I require a file in meteor 1.3?

I'm trying to use react-datepicker in a meteor 1.3 and react project.

Everything is working fine except that I don't have access to any of the css in the package. The readme says I need to require the css file from the package.

If I wasn't using meteor I could start the file with:

var React = require('react');
var DatePicker = require('react-datepicker');
var moment = require('moment');

require('react-datepicker/dist/react-datepicker.css');

Since this is meteor 1.3 I started it with

import React from 'react';
import DatePicker from 'react-datepicker';
import moment from 'moment';

I don't know how to require the css file. Can anybody explain this?

The only workaround I found was using relative paths inside an .scss file.

@import "./../../../../node_modules/react-date-picker/base.css";
@import "./../../../../node_modules/react-date-picker/theme/hackerone.css";

Ugly as f***, I know, but it works.

import 'react-datepicker/dist/react-datepicker.css'; worked! Thanks @apendua

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM