How i can dynamically generate bower_components with bower.json using gulp - gulp

I want to install dependencies listed in bower.json or package.json using gulp .
NOTE : I have deleted bower_components folder and I want when i run gulp task to install bower.json dependencies . How I can achieve that?

You can you this gulp module : https://www.npmjs.com/package/gulp-bower
It allows you execute bower commands such as install and update.

Related

Use global gulp in a project

How can I use globally installed gulp in a project where I have gulpfile.js without installing gulp in that project or linking it to global gulp.
When I type
$ gulp --version
I get:
CLI version 3.9.1
but when I type:
$ gulp
I get:
Local gulp not found in
I do not want any additional files nor directories created in the path-of-my-project just want to use globally installed gulp.
I want to use the gulp in the project-dir or pass the path to project-dir as a parameter.
In the project-dir I have only gulpfile.js and want to have only that file related to gulp.
How to do that?

grunt - config object

This sample grunt file https://gruntjs.com/sample-gruntfile reads in a config object from package.json and stores it in the pkg property:
pkg: grunt.file.readJSON('package.json')
However, the page doesn't give a sample package.json file. Later on it refers to pkg.name. I assume this is a top level key in package.json. E.g.
{
"name": "this value here",
}
Is that correct?
Yes that's correct.
The package.json file is the heart of npm which is used by grunt.
You can generate one for your project using npm initand filling out the options or you can manually create and update it.
It gets updated automatically when using the --save option when adding modules to grunt.
npm install grunt-contrib-copy --save
This will install the module to your node_modules folder and update the dependencies section in your package.json
You only need to save the package.json file in your repo and each developer can download all dependencies listed in your package.json by calling npm install

npm recursive install bower dependencies

I have multiple node modules developed by myself stored on a private gitlab server. In my Project, i install those modules with bower, so my Project structure Looks like this:
appname
bower_components
module1
...
package.json
module2
...
node_modules
...
package.json
When i call npm install only the dependencies from the package.json file located in the Folder "appname" will be installed. The Problem is, that my modules, which i install with bower, also have dependencies, which are not listed in the package.json in the root Folder. How can i install those dependencies without installing them globally? It should by something like npm install bower_components\module1. I also tried to use the command line Option --prefix but it only copies the Folder inside the node_modules Folder.
Thanks for your help

How run Polymer code example?

I have downloaded this example : PolymerElements/app-layout-templates
..and I can't make it work (whereas I was able to access this one : PolymerElements/polymer-starter-kit)
I ran the following lines in the terminal :
bower init
bower -save polymer
bower bower install –save Polymer/polymer-elements Polymer/polymer-ui-elements
bower update
...and then accessed the folder via a python server.
Do you have some tips to make it work ?
If you want to try out PolymerElements/app-layout-templates then that's what you need to install on bower. Bower will download all the required dependencies for app-layout-templates to work.
bower install --save PolymerElements/app-layout-templates
After this you can start python server on folders app-layout-template, app-layout-template/nav-view etc to see how it works.
Also the repositories Polymer/polymer-elements, Polymer/polymer-ui-elements are invalid. The polymer elements are available in github repository https://github.com/PolymerElements. So to download polymer elements try something like below
bower install --save PolymerElements/iron-elements
bower install --save PolymerElements/paper-elements
bower install --save PolymerElements/neon-elements
bower install --save PolymerElements/platinum-elements

Is bower_components special or unique in some way that it isn't served up on a website?

I installed Polymer using the following commands:
bower init
bower install --save Polymer/polymer#^1.1.0
bower install --save PolymerElements/paper-elements
It created a subfolder called bower_components. But none of the files were found until I copied them to a different subfolder, and then everything started working.
Why is that?
Perhaps you want to install your bower components in the "different subfolder" by default. This can be done using the following in .bowerrc:
{
"directory": "some/directory"
}
Hope that helps.
bower_components is created when you invoke bower install. All deps in bower.json will be downloaded there.