harp icon indicating copy to clipboard operation
harp copied to clipboard

Add vendor path to be ignored

Open turizoft opened this issue 10 years ago • 13 comments

Greetings, I've been using Harp.js from some time ago and I realized that when one wants to compile a project, harp will work with each file it finds inside project folder. This can be a drawback when working with tools like Bower. Which creates a subfolder for components a.k.a bower_components. I've seen the open issue about this, but there is no PR yet.

I figured out that the simplest way to do this is passing the compile command a parameter specifying the location of the vendor folder, by default inside [publicPath]/vendor. Harp will ignore this path when compiling and will copy it without altering it to the outputPath.

I read somewhere that .gitignore can be used for this purposes, but knowing that harp's approach is simplicity, I think this solution addresses the problem properly, since it decouples the solution from other factors (like git). And I'd say it covers the 80% or 90% percent of cases when someone needs to ignore a folder.

With respect to the code all test are passing and I've followed harp's coding style.

I've already used this for one mobile app we're developing with Phonegap and an API based static web app. So far so good. No errors and now I can use bower with ease.

I'm keen to any commentary,

Néstor Turizo

turizoft avatar Jul 15 '14 22:07 turizoft

Awesome. I have a couple of projects using npm, I am looking forward to trying them with your fork and will post feedback after. Thanks so much for the hard work.

kennethormandy avatar Jul 15 '14 23:07 kennethormandy

This seems to break a bunch of tests, but I’m guessing it’s because the vendor path and output path arguments are switched and the output path was being used in the tests. Is there any reason you switched these around?

kennethormandy avatar Jul 15 '14 23:07 kennethormandy

Sorry about the tests! I was going to add the parameter after the output path, but then I thought its more common to leave output path unspecified (default to www) than the vendor path, it could change more often, like: "bower components" or "vendor".

turizoft avatar Jul 16 '14 00:07 turizoft

This looks great to me. You're right, a simple vendorPath should cover all the use cases. Thanks @turizoft !

jevets avatar Jul 16 '14 15:07 jevets

+1

GeoffreyPlitt avatar Sep 07 '14 22:09 GeoffreyPlitt

Looks like @kennethormandy is planning a different approach as written in #438. Are there any plans when this feature will be implemented? My biggest problem is that compilation fails because of some files inside public/bower_components/. I think this is a pretty big show-stopper.

electerious avatar Jun 13 '15 21:06 electerious

+1, I stopped using this tool because it was failing on my bower components, I think it's a show-stopper for most people.

On Sat, Jun 13, 2015 at 2:09 PM, Tobias Reich [email protected] wrote:

Looks like @kennethormandy https://github.com/kennethormandy is planning a different approach as written in #438 https://github.com/sintaxi/harp/pull/438. Are there any plans when this feature will be implemented? My biggest problem is that compilation fails because of some files inside public/bower_components/. I think this is a pretty big show-stopper.

— Reply to this email directly or view it on GitHub https://github.com/sintaxi/harp/pull/312#issuecomment-111752735.

http://www.geoffplitt.com http://facebook.com/geoffrey.plitt https://twitter.com/GeoffreyPlitt 773.339.0915

GeoffreyPlitt avatar Jun 13 '15 23:06 GeoffreyPlitt

@electerious @GeoffreyPlitt Not sure if it helps, but I've since switched to Browserify instead of Bower. Been working great for me with a couple easy npm package scripts. This assumes you're building and deploying static files.

Something like

  "scripts": {
    "serve": "harp server",
    "build-js": "browserify public/js/app.js > public/js/bundle.js",
    "watch-js": "watchify public/js/app.js -o public/js/bundle.js",
    "dev": "npm run watch-js & npm run serve",
    "build": "npm run build-js && harp compile"
  }

jevets avatar Jun 15 '15 14:06 jevets

Hey @kennethormandy or @sintaxi ... Maybe it would make sense to add node_modules to the default ignore subset and add bower_components and maybe vendor to the default copy subset?

That is of course if it is an easier route than letting people specify files for both of these cases in the harp.json file.

That would clear up all of the cases where harp compile falls over for me and I'm sure many others. Anything else you can work around. I currently find myself adding and removing my node_modules folder just to compile. I also end up having to gut what I need from what seems to be every other bower project to do the same.

howardroark avatar Jun 29 '15 19:06 howardroark

Is there any final solution for this issue? Seems has been forgotten but is a real pain dealing with workarounds for ignoring folders...

miljan-aleksic avatar Sep 20 '15 09:09 miljan-aleksic

Still an issue for me as well....

jtraband avatar Sep 27 '15 23:09 jtraband

+1 for .harpignore for README.md and node_modules

danactive avatar Oct 11 '15 01:10 danactive

With 0.24 the lack of ignored node_modules started breaking our build. an non-compiled public/node_modules in any way would be much appreciated.

Kilian avatar Jun 12 '17 11:06 Kilian