M
M
Maxim Gatilin2015-06-17 10:14:56
Layout
Maxim Gatilin, 2015-06-17 10:14:56

How not to prescribe gulp install every time?

Every time I start a project on gulp (a clone from git), I write a line like this in the console:
npm install gulp gulp-jade gulp-sass gulp-csso gulp-imagemin imagemin-pngquant gulp-uglify gulp-concat gulp-connect gulp-open --save-dev Is there any
way to automate this process?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexey Ukolov, 2015-06-17
@gatilin222

Create a standard package.json , throw it into the project folder and run npm install .
More serious automation is required if you create a project more often than at least once a day.

A
Andrey B., 2015-06-17
@andykov

After you write the --save-dev flag, the plugin or plugins in your case are written to the package.json file
like this:

"devDependencies": {
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^2.1.0",
  }

Further, in order not to write them every time, just enter npm install and everything that is in devDependencies will be installed.
Those. you need to keep the package.json file in the git with the dependencies already written.

L
lnked, 2015-06-17
@lnked

I wrote a shell script for this, creating a new project looks like this ./install.sh

#!/bin/bash 

folder_name=$1 #присваиваем переменной parametr1 значение первого параметра скрипта

# тут нужно указать правильный путь
ROOT='/Applications/MAMP/htdocs/markup.dev'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'

echo -e " "

# Создаем папку проекта если ее нет
#
if [ -d "$folder_name" ] ; then
  echo -e "${RED}Папка $folder_name существует${NC}\n"
else
  mkdir $folder_name
  echo -e "${GREEN}Создана папка $folder_name${NC} \n"
fi

# Переходим в папку
#
cd ./$folder_name

# создаем ссылку на папку node_modules, в итоге у нас 1 папка с плагинами и диск не захламляется 
ln -s ${ROOT}/clean/node_modules/ ${ROOT}/$folder_name/

mkdir assets dist assets/template assets/scripts assets/images assets/styles assets/fonts

# Копируем файлы

cp -r ${ROOT}/clean/.jshintrc ${ROOT}/$folder_name/.jshintrc
cp -r ${ROOT}/clean/gulpfile.js ${ROOT}/$folder_name/gulpfile.js
cp -r ${ROOT}/clean/package.json ${ROOT}/$folder_name/package.json
cp -r ${ROOT}/clean/assets/template/* ${ROOT}/$folder_name/assets/template/
cp -r ${ROOT}/clean/assets/styles/* ${ROOT}/$folder_name/assets/styles/
cp -r ${ROOT}/clean/assets/scripts/* ${ROOT}/$folder_name/assets/scripts/

echo -e "Проект ${GREEN}$folder_name${NC} успешно создан"

gulp build
gulp

exit 0

S
Sergey, 2015-06-18
Protko @Fesor

There is also yoman , which was invented specifically to automate the creation of basic applications. The only thing is that you have to write a template for the application, but it comes out very flexible.

A
Alexey Sosnovsky, 2015-07-17
@sosnovskyas

YO or yoman. it is used in many places and already has many ready-made templates, and in the end you can make your own or correct an existing one. Make a handful of templates for typical projects and go

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question