how to wrap a library without build files in meteor package - meteor

I try to wrap a javascript library with a meteor package.
When i fork the library it has no built javascript file inside the repository. Normally someone would run grunt dist to build the dist/library.js file.
Meteor Package description:
Package.onUse(function(api) {
api.addFiles([
'dist/library.js',
])
})M
this can't work because the file does not exist yet.
How can i create a package from that library? is coping the library.js file the only way?

If you want to do this, you're going to have to require Grunt, run Grunt through the JavaScript API (not the CLI) to compile dist/library.js, and then require it.
It would be much easier to just compile it outside of Meteor and place it in the folder, but if you want to do things The Right Way™ that's how you'd do it. Let me know if you have any implementation-specific questions!

Related

How to use Laravel 5 with Gulp, Elixir and Bower?

I am completely new to all this, 'Bower' and 'Gulp' and Laravel 'Elixir'. I purchased a template that uses them (unfortunately) and now I need some help on how to go about implementing them. I have already installed NPM and Bower. All my packages have been downloaded into:
resources > assets > vendor
This is a screenshot:
Now my question is how do I include all those packages I downloaded in my view? From my understanding I can't run less files directly in the browser, it only runs once due to 'browser caching' or something like that, also the JS scripts are just too many to include in my page.
I want a way where I can work on my files and have them automatically compiled with the compiled files being referenced in my app.php file.
This is a link to the GulpJS file included in my template: http://pastebin.com/3PSN6NZY
You do not need to compile every time someone visits. The compiled sass/js should be run in dev and then the output files referenced.
If you have gulp installed on the project, you should see a gulp.js file in the root of your project. If not, visit here for instructions:
Gulp/Elixer installation and setup
In your gulp.js file:
var elixir = require('laravel-elixir');
elixir(function(mix) {
mix.less([
'app.less',
'normalize.less',
'some-other-less.less',
'and-another.less'
]);
mix.scripts(['app.js', 'some-other-js.js'], 'public/js/output-file.js');
});
While in development you can run gulp watch from the command line to listen for changes and run compile tasks when it hears a change. Then you simply reference the output files in the public directory as you normally would.
If you don't want to listen, you can just run the gulp command for a single once-off task run.
The docs are pretty straight forward and can be found here:
Gulp/Elixer docs

Meteor + PhantomJS how to make it work

im trying to install PhantomJS in a MeteorApp.
I have done those step:
Add the npm package
meteor add meteorhacks:npm
Run meteor to let the npm package to pre-initialise
meteor
A file packages.json has been created at the root. Edit it to:
{
"phantomjs": "1.9.13"
}
A this point everything seem to work. But i try to test with this exemple that ive found here :
https://github.com/gadicc/meteor-phantomjs
But i dont understand where to put my phantomDriver.js
Why is phantomDriver.js is in assets/app/phantomDriver.js... but after, they say to create the file in ./private/phantomDriver.js...
Thank for clear explication :)
In development mode you create the file in /private/phantomDriver.js. When you build a meteor app it refactors everything into an application bundle which can be run.
After meteor builds your app it stores stuff from private into assets. For phantomjs to execute this file it needs to look in this directory. You don't have to create it. This is how meteor works internally.
If you look in your .meteor/local/build/programs/server directory the assets directory is there with anything you placed in private.
From the context of where your meteor code runs (the server directory above) the assets directory runs from this directory when your project is running.
Keep in mind when you deploy your app it loses its entire project structure and becomes something else. Gadi's phantomjs project is designed to work in production environments too.
TLDR; Don't worry about the assets directory, keep your file in /private/phantomDriver.js. Meteor should take care of the rest.

Is it possible to setup Gulp in a distributed fashion?

Here's what I want to do:
Create a node package that features the following:
gulpfile.js
All gulp plugins, tasks, configs.
Install this node package (referred to as "my-gulp" from here on) within an Angular app (referred to as "myApp" from here on) via package.json dependencies.
gulpfile.js is copied into app root.
All Gulp tasks can be run from app.
We currently have something similar setup with Grunt (although without the Gruntfile.js copy stuff). It works pretty well to have a common setup for each of our apps, but also several custom Bower components. Just have to bring it in as a dependency and it magically works.
The main issue I've run into so far is when I add my-gulp to myApp's dependencies, run the install, my-gulp comes in just fine, however the individual plugins (my-gulp dependencies) aren't seen. They're installed, but running something like gulp default or whatever shows them missing.
I've tried to setup Gulp dependencies (in my-gulp) under "dependencies" as opposed to "devDependencies", yet still not quite working.
Does anyone have any experience doing something like this?
Am I doing something blatantly stupid here?
Any help is awesome!
Thanks, everyone :)
The problem is the way npm handles nested dependencies. When you install your "my-gulp" package, the directory tree looks like this:
| myApp
|-- node_modules
|-- my-gulp
|-- node_modules
|-- gulp_dependency
As you can see, the dependencies of "my-gulp" are buried inside its own node_modules directory. myApp cannot access them.
You could use something like npm-flatten to move those to the top directory. Otherwise you'll be forced to add each dependency to myApp's package.json.
Edit:
As indicated in your gist, you can load the dependencies by path instead of package name. Instead of copying your gulpfile, simply require it from myApp, then load its dependencies with a relative path:
// myApp/gulpfile.js
require('my-gulp/gulpfile.js');
// my-gulp/gulpfile.js
var gulpDep = require('./node_modules/gulp-dependency');
Note: This won't work if you use npm dedupe.

Meteor package naming error

I've been working on a Meteor package for some time now and I have been been using a Meteor SCSS build package to compile my sass. Now for reasons like autoprefixer and such, I need to compile the SCSS outside of Meteor. My plan was to use Codekit but when I try to build the SCSS I get an error with no message at all. When I use the Sublime Text 2 SCSS build package I get an error as well. I have come to the conclusion that this is because of my Meteor package name. I have named it:
myusername:packagename
and as a folder that translates to
myusername/packagename
It replaces : with / and because of that, Codekit thinks the folder named myusername/packagename is two folders myusername -> packagename. That messes up the folder tree when Codekit tries to compile it.
Is there a good way to handle this?
To solve this problem, you can rename the directory of the package and then add an entry inside the Package.describe call in package.js:
Package.describe({
summary: "My package",
version: "0.0.1",
name: "myusername:packagename"
});
Now, the name of the package will be read from package.js and the directory can be called whatever you want.

How to tell Meteor to ignore `gulpfile.js`

In my meteor project I want to use gulp for tasks meteor doesn't support.
Anyway, the problem is that gulp uses a file called gulpfile.js which is loaded by meteor too and gives errors. So my question is, is there a way to tell meteor to ignore some files ?
UPDATE: One solution I can think of is to put gulpfile.js in the folder packages or public and run gulp as follows
$> gulp --gulpfile packages/gulpfile.js
UPDATE: Just noticed that meteor also seems to load node_modules files :(
Unfortunately, in the current release there's no way to tell Meteor to leave certain files alone, so you cannot have gulpfile.js in your main app folder.
You can, however, leave it in an ignored subfolder. Meteor ignores files and directories that ends with tilde ~, the /tests directory and all private files (those beginning with a dot .). So you can create a folder named for example gulp~ and use it for your gulp-related stuff.
The same holds for node_modules folder, you cannot have it in your application, and you shouldn't. If you want to use a node package in your Meteor application, you can do this with npm package.
Add it to your project with mrt add npm command.
Then create packages.json file with a list of all required packages, for example:
{
"something": "1.5.0",
"something-else": "0.9.11"
}
Afterwards, include your package with Meteor.require:
var something = Meteor.require('something');
If you want to use a node package in your gulp tasks, install it inside the ignored directory.

Resources