I have a package which includes a file that gets frequently rebuilt. This causes meteor to restart each time that file is edited.
There are ways to get meteor to ignore files within the main app, eg putting inside a .directory but is there a way to do this within a package?
The catch is that I DO need the final file to be included for deployment, so it has to be named - as an asset - and included in the package addFiles.
The only solution I have so far is to host the asset external to the meteor app and load it in via http or something on each cold start, but that's a bit fragile.
As of Meteor v1.5.2.1, there is support for a .meteorignore file. It behaves the same as a .gitignore. Have you tried using it?
You can use them in any directory of your project and are fully integrated with the file watching system.
Related
I need to bundle some data files (geoip data) with my meteor application. Simply putting the data files in my application directory doesn't appear to do anything - they're not copied to anywhere in .meteor/local/build when I run meteor.
How can I make meteor copy these files when it builds my application?
So, files are loaded on different environment is a specific order. Have a look here for details on what's loaded where and when.
https://guide.meteor.com/structure.html#load-order
Then you can decide where best to place the file depending on the use case.
I'd like to do the inverse of this question/answer:
How to include TypeScript files when publishing?
The thing is that I'm trying to publish an ASP.NET MVC 5 Project. Unfortunately the dreaded Visual Studio and the hungry Jack Typescript interpreter ignores any tsconfig.json file and decides to go deep down and look for any .ts file that is not accompanied by a .js. I have lots of npm packages nested down and some of them have uncompiled typescript files.
Funny thing is, that they are not included in the project (not even an exclamation mark). (I even checked for the .csproj and no files were found).
Is this a bug? How can I prevent this from happening? Using VS 2015.2 (Update 2).
I had a very similar issue. Publish kept failing because it couldn't find foo.js as it wasn't in the same directory as my ts/tsconfig files, even though outDir was set to another location. I don't know if it is a bug or not but I couldn't figure it out using the tsconfig. Instead, I was able to get things working by using the inbuilt TypeScript Build settings instead.
First, I deleted all tsconfig files from my project (I made sure I kept a backup just in case). The TypeScript Build was originally greyed out because I had the tsconfig files in my project.
Next, I created a new folder directly under Scripts to save the js files into.
I then went to Project Properties and selected the TypeScript Build tab. Under Output, I checked the Redirect JavaScript output to directory and browsed to the newly created folder. I repeated this for all build configurations.
Finally, I included the new folder in my project and then built. Folders and files which aren't included in the project can be seen as a ghost icon in the Solution Explorer if you have Show All Files icon selected. I think that if you have multiple TypeScript projects with their own tsconfigs, the file structures are replicated under the chosen output directory but I haven't tested it in many cases so I'm not certain.
Obviously I had to redirect my script bundles to the newly created js structure.
When I first followed this process, I got a few build errors mainly due to my own daft mistakes in my TypeScript code which I'd set the tsconfig to conveniently ignore. Another error was multiple references for objects, which I managed to fix by deleting the definitions files and making sure that the Generate declaration files option was unchecked in Typescript Build. Once I fixed those issues though, I was able to publish without that annoying error - happy days!
I'm working on building a package for meteor 0.9+ that exposes a library off sass mixins called 'Bourbon' and am trying to sort out the best way to provide access to '#import' a stylesheet from the package into a Meteor project.
https://github.com/wolvesio/meteor-bourbon/
Pre Meteor 0.9 this used to be done via something along the lines of:
#import "packages/wolves:bourbon/bourbon";
Since the package system changed though this no longer works. Any help as to the best way to do this moving forward would be greatly appreciated.
I've managed to accomplish what you want, it's a bit hacky but it works at last.
First, you need to add the .less files as server assets in your package :
Package.onUse(function(api){
api.addFiles([
"bourbon/style1.less",
...
"bourbon/styleN.less"
],"server",{
isAsset:true
});
});
Then run meteor to trigger the building of your application : this will copy over the server assets to the .meteor directory of your application. More precisely, your .less files will now live in ".meteor/local/build/programs/server/assets/packages/wolves:bourbon/bourbon/*".
Now you can reference these .less files in your application using this super unfriendly path.
I recommend hiding this stuff from your package users by defining an import.less directly in the package :
packages/wolves:bourbon/bourbon.import.less
#bourbon-root: ".meteor/local/build/programs/server/assets/packages/wolves:bourbon/bourbon/";
#import "#{bourbon-root}style1.less";
//
#import "#{bourbon-root}styleN.less";
Then in the package README, invite your users to simply copy bourbon.import.less in their client directory and reference it from there.
client/lib/config/style.less
#import "bourbon.import.less";
There is one drawback to this approach that I was unable to solve at the moment : the .less files are copied in the .meteor directory when your application is built (a process that happens when triggering meteor run).
However, the build process will try to compile your application .less files FIRST, before copying the server assets (in this case our package .less files) to the .meteor dir.
So the very first time you add the package to an app, it will complain that it is unable to find the package .less files, triggering a rebuild (either by killing and relaunching meteor or touching your application .less files) will fix this though.
Is there some specific folder in Meteor file structure which is simply ignored by Meteor? (meteor bundle and meteor deploy etc)
Or better yet: is there a kind of .meteorignore file where we can list files for Meteor to ignore?
There's no such file as .meteorignore yet.
Currently the only reliable way to hide a file from Meteor is to make it hidden (add a dot to the beginning of name). You can hide the whole directory, which is useful if you need specific filenames for things like Grunt tasks.
For example if you create a directory called .hammerTime, then Meteor can't touch this.
Update:
As of Meteor v1.5.2.1, there is support for a .meteorignore file. It works exactly the same as a .gitignore.
As of Meteor v1.5.2.1, there is support for a .meteorignore file. It works exactly the same as a .gitignore.
You can use them in any directory of your project and are fully integrated with the file watching system.
Tl;dr : Is there an equivalent in meteor to .gitignore?
Yes, I am aware of using a leading '.' in the directory name to get meteor to exclude it. But using leading dot is not a solution in this case. Read below to understand.
Longer:
I would like to use Bower.io to install various browser plugins.
Ideally, I run bower in the client subdirectory. Bower does its thing creating the bower_components directory and pulls down the plugin (pick a random jquery plugin for example).
Many plugins include example html, demo css files, etc. to show how to use the plugin.
Unfortunately, Meteor wants to include all that stuff in the application. Which unsurprisingly causes problems.
My current solution is to have bower.io run in the project's parent directory. This is not ideal as I have to copy js/css files over from the bower directory to the meteor client directory. (yes, I could use soft links but then the files would be missing when pushing to production).
With only a few client plugins / css packages this is becoming quite annoying.
NOTE: Renaming files/directories retrieved by bower.io to have a leading '.' or using bower in a dotted subdirectory helps only marginally. I would then have to manually include the files needed.
Is this possibly a duplicate of How to exclude directories/files from Meteor's bundler?
If you want to define the way you name your files, you could try including a certain regex to match in the meteor bundler. Otherwise, maybe it's something that needs to be implemented on a framework level.
I also found this tutorial by Tri on integrating meteor and bower: http://tridnguyen.com/articles/meteor-and-bower/. Tri defines a new meteor package to specify the exact files required on the client.
The best solution, however, is move away from Bower as Meteor offers its own package manager at a framework level. Including the front end files that you need using Meteor packages would be the more productive solution in the long run, especially as the framework changes.