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?
To use an npm package from a file in your application you import the name of the package: import moment from 'moment'; // this is equivalent to the standard node require: const moment = require('moment'); This imports the default export from the package into the symbol moment .
What does it do? The Meteor build tool is what compiles, runs, deploys, and publishes all of your Meteor apps and packages. It's Meteor's built-in solution to the problems also solved by tools like Grunt, Gulp, Webpack, Browserify, Nodemon, and many others, and uses many popular Node.
By default, npm install will install all modules listed as dependencies in package. json .
npm is two things: first and foremost, it is an online repository for the publishing of open-source Node. js projects; second, it is a command-line utility for interacting with said repository that aids in package installation, version management, and dependency management.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With